I'm trying to create the full path all at once if it doesn't already exist, but I'm not sure it's possible. This is my code now:
absolute_path = '/home/{signup_code}/{resource}/process'
missing_file = absolute_path.format(resource='agents', signup_code=signup_code)
with open(missing_file, 'a') as f:
f.write(listing_kwargs['agent_id'] + "\n")
And this is the error I'm getting:
FileNotFoundError: [Errno 2] No such file or directory: '/home/ith/agents/process'
Or do I have to do something like this:
path = '/home/{signup_code}/{resource}/'
os.makedirs(path, exist_ok=True)
process = os.path.join(path, 'process')
with open(process, 'a') as f:
f.write(listing_kwargs['agent_id'] + "\n")