From 8a1bc1d5ec2af407fb367fa96b2de2945fdabfbe Mon Sep 17 00:00:00 2001 From: Hoffelhas Date: Sun, 15 Jan 2023 21:55:30 +0100 Subject: [PATCH] Final preparations for v2.0 --- autodoist.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/autodoist.py b/autodoist.py index 0801213..720a9c8 100644 --- a/autodoist.py +++ b/autodoist.py @@ -362,13 +362,19 @@ def initialise_api(args): # Run the initial sync logging.debug('Connecting to the Todoist API') - api_arguments = {'token': args.api_key} - api = TodoistAPI(**api_arguments) - logging.info("Autodoist has successfully connected to Todoist!") + try: + api_arguments = {'token': args.api_key} + api = TodoistAPI(**api_arguments) + sync_api = initialise_sync_api(api) + # Save SYNC API token to enable partial syncs + api.sync_token = sync_api['sync_token'] + + except Exception as e: + logging.error( + f"Could not connect to Todoist: '{e}'") + exit(0) - sync_api = initialise_sync_api(api) - # Save SYNC API token to enable partial syncs - api.sync_token = sync_api['sync_token'] + logging.info("Autodoist has successfully connected to Todoist!") # Check if labels exist