Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion td/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,15 @@ def _state_manager(self, action: str) -> None:
self.state.update(json.load(json_file))

# if they want to save it and have allowed for caching then load the file.
elif action == 'save':
elif action == 'save':
# Create parent directory if it doesn't exist
if not credentials_file_exists:
try:
os.makedirs(os.path.dirname(self.credentials_path))
except OSError as exc: # Guard against race condition
if exc.errno != errno.EEXIST:
raise
# Save file
with open(file=self.credentials_path, mode='w+') as json_file:
json.dump(obj=self.state, fp=json_file, indent=4)

Expand Down