From 2dcc7e39102cb956d3afaabc38687a59dfbfc550 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 19 Feb 2020 15:18:41 +0100 Subject: [PATCH] making sync work --- rowers/uploads.py | 115 +++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 67 deletions(-) diff --git a/rowers/uploads.py b/rowers/uploads.py index 7f94106d..a26fe6a3 100644 --- a/rowers/uploads.py +++ b/rowers/uploads.py @@ -516,79 +516,60 @@ def do_sync(w,options): except KeyError: pass - if ('upload_to_C2' in options and options['upload_to_C2']) or (w.user.c2_auto_export and ispromember(w.user)): - if ('upload_to_C2' in options and not options['upload_to_C2']): - pass - else: - try: - message,id = c2stuff.workout_c2_upload(w.user.user,w) - except NoTokenError: - id = 0 - message = "Something went wrong with the Concept2 sync" - if ('upload_to_Strava' in options and options['upload_to_Strava']) or (w.user.strava_auto_export and ispromember(w.user)): - if ('upload_to_Strava' in options and not options['upload_to_Strava']): - pass - else: - try: - message,id = stravastuff.workout_strava_upload( + if ('upload_to_C2' in options and options['upload_to_C2']) or (w.user.c2_auto_export and ispromember(w.user.user)): + try: + message,id = c2stuff.workout_c2_upload(w.user.user,w) + except NoTokenError: + id = 0 + message = "Something went wrong with the Concept2 sync" + + if ('upload_to_Strava' in options and options['upload_to_Strava']) or (w.user.strava_auto_export and ispromember(w.user.user)): + try: + message,id = stravastuff.workout_strava_upload( + w.user.user,w + ) + except NoTokenError: + id = 0 + message = "Please connect to Strava first" + + + if ('upload_to_SportTracks' in options and options['upload_to_SportTracks']) or (w.user.sporttracks_auto_export and ispromember(w.user.user)): + try: + message,id = sporttracksstuff.workout_sporttracks_upload( w.user.user,w - ) - except NoTokenError: - id = 0 - message = "Please connect to Strava first" + ) + except NoTokenError: + message = "Please connect to SportTracks first" + id = 0 - if ('upload_to_SportTracks' in options and options['upload_to_SportTracks']) or (w.user.sporttracks_auto_export and ispromember(w.user)): - if ('upload_to_SportTracks' in options and not options['upload_to_SportTracks']): - pass - else: + if ('upload_to_RunKeeper' in options and options['upload_to_RunKeeper']) or (w.user.runkeeper_auto_export and ispromember(w.user.user)): + try: + message,id = runkeeperstuff.workout_runkeeper_upload( + w.user.user,w + ) + except NoTokenError: + message = "Please connect to Runkeeper first" + id = 0 - try: - message,id = sporttracksstuff.workout_sporttracks_upload( - w.user.user,w - ) - except NoTokenError: - message = "Please connect to SportTracks first" - id = 0 + if ('upload_to_MapMyFitness' in options and options['upload_to_MapMyFitness']) or (w.user.mapmyfitness_auto_export and ispromember(w.user.user)): + try: + message,id = underarmourstuff.workout_ua_upload( + w.user.user,w + ) + except NoTokenError: + message = "Please connect to MapMyFitness first" + id = 0 - if ('upload_to_RunKeeper' in options and options['upload_to_RunKeeper']) or (w.user.runkeeper_auto_export and ispromember(w.user)): - if ('upload_to_RunKeeper' in options and not options['upload_to_RunKeeper']): - pass - else: - - try: - message,id = runkeeperstuff.workout_runkeeper_upload( - w.user.user,w - ) - except NoTokenError: - message = "Please connect to Runkeeper first" - id = 0 - - if ('upload_to_MapMyFitness' in options and options['upload_to_MapMyFitness']) or (w.user.mapmyfitness_auto_export and ispromember(w.user)): - if ('upload_to_MapMyFitness' in options and not options['upload_to_MapMyFitness']): - pass - else: - try: - message,id = underarmourstuff.workout_ua_upload( - w.user.user,w - ) - except NoTokenError: - message = "Please connect to MapMyFitness first" - id = 0 - - - if ('upload_to_TrainingPeaks' in options and options['upload_to_TrainingPeaks']) or (w.user.trainingpeaks_auto_export and ispromember(w.user)): - if ('upload_to_TrainingPeaks' in options and not options['upload_to_TrainingPeaks']): - pass - else: - try: - message,id = tpstuff.workout_tp_upload( - w.user.user,w - ) - except NoTokenError: - message = "Please connect to TrainingPeaks first" - id = 0 + if ('upload_to_TrainingPeaks' in options and options['upload_to_TrainingPeaks']) or (w.user.trainingpeaks_auto_export and ispromember(w.user.user)): + try: + message,id = tpstuff.workout_tp_upload( + w.user.user,w + ) + except NoTokenError: + message = "Please connect to TrainingPeaks first" + id = 0 return 1