Put second sync back in, for some reason this makes it much more stable.

Final testing concluded, pushing for release.
master
Hoffelhas 2020-05-30 13:49:37 +02:00
parent a552954d8b
commit ff31adc65b
1 changed files with 12 additions and 10 deletions

View File

@ -21,7 +21,7 @@ def make_wide(formatter, w=120, h=36):
formatter(None, **kwargs) formatter(None, **kwargs)
return lambda prog: formatter(prog, **kwargs) return lambda prog: formatter(prog, **kwargs)
except TypeError: except TypeError:
warnings.warn("argparse help formatter failed, falling back.") logging.error("Argparse help formatter failed, falling back.")
return formatter return formatter
@ -72,6 +72,15 @@ def main():
logging.StreamHandler()] logging.StreamHandler()]
) )
def sync(api):
try:
logging.debug('Syncing the current state from the API')
api.sync()
except Exception as e:
logging.exception(
'Error trying to sync with Todoist API: %s' % str(e))
quit()
def initialise(args): def initialise(args):
# Check we have a API key # Check we have a API key
@ -98,14 +107,7 @@ def main():
api_arguments['cache'] = None api_arguments['cache'] = None
api = TodoistAPI(**api_arguments) api = TodoistAPI(**api_arguments)
sync(api)
try:
logging.debug('Syncing the current state from the API')
api.sync()
except Exception as e:
logging.exception(
'Error trying to sync with Todoist API: %s' % str(e))
quit()
# Check if label argument is used # Check if label argument is used
if args.label is not None: if args.label is not None:
@ -250,6 +252,7 @@ def main():
while True: while True:
overview_item_ids = {} overview_item_ids = {}
overview_item_labels = {} overview_item_labels = {}
sync(api)
for project in api.projects.all(): for project in api.projects.all():
@ -503,6 +506,5 @@ def main():
logging.debug('Sleeping for %d seconds', args.delay) logging.debug('Sleeping for %d seconds', args.delay)
time.sleep(args.delay) time.sleep(args.delay)
if __name__ == '__main__': if __name__ == '__main__':
main() main()