From 47a6545eac09ee70d60c4d9c82990772e41d27b9 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Fri, 15 Nov 2019 08:08:11 +0100 Subject: [PATCH] forgot to save --- rowers/uploads.py | 55 ++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/rowers/uploads.py b/rowers/uploads.py index ee8d17b3..93215e2c 100644 --- a/rowers/uploads.py +++ b/rowers/uploads.py @@ -48,12 +48,12 @@ def cleanbody(body): body = body.decode('utf-8') except AttributeError: pass - + regex = r".*---\n([\s\S]*?)\.\.\..*" matches = re.finditer(regex,body) for m in matches: - + if m != None: body = m.group(0) @@ -112,7 +112,7 @@ def matchrace(line): return None return None - + def matchsync(line): results = [] tester = '((sync)|(synchronization)|(export))' @@ -175,7 +175,7 @@ def gettypeoptions_body2(uploadoptions,body): break return uploadoptions - + def getprivateoptions_body2(uploadoptions,body): tester = re.compile('^(priva)') for line in body.splitlines(): @@ -206,7 +206,7 @@ def getplotoptions_body2(uploadoptions,body): if chart: uploadoptions['make_plot'] = True uploadoptions['plottype'] = chart - + return uploadoptions def getuseroptions_body2(uploadoptions,body): @@ -236,7 +236,7 @@ def getsyncoptions_body2(uploadoptions,body): uploadoptions[r] = True return uploadoptions - + def getsyncoptions(uploadoptions,values): try: value = values.lower() @@ -247,7 +247,7 @@ def getsyncoptions(uploadoptions,values): for v in values: try: v = v.lower() - + if v in ['c2','concept2','logbook']: uploadoptions['upload_to_C2'] = True if v in ['tp','trainingpeaks']: @@ -262,7 +262,7 @@ def getsyncoptions(uploadoptions,values): uploadoptions['upload_to_MapMyFitness'] = True except AttributeError: pass - + return uploadoptions def getplotoptions(uploadoptions,value): @@ -437,7 +437,7 @@ def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0): if plotnr == 0: plotnr = plotnrs[plottype] - + if w.workouttype in otwtypes: plotnr = plotnr+3 @@ -445,20 +445,20 @@ def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0): job = myqueue(queuehigh,handle_makeplot,f1,f2, title,hrpwrdata, plotnr,imagename) - + try: width,height = Image.open(fullpathimagename).size except: width = 1200 height = 600 - + imgs = GraphImage.objects.filter(workout=w) if len(imgs) < 7: i = GraphImage(workout=w, creationdatetime=timezone.now(), filename=fullpathimagename, width=width,height=height) - + i.save() else: return 0,'You have reached the maximum number of static images for this workout. Delete an image first' @@ -501,7 +501,7 @@ def make_private(w,options): return 1 from rowers.utils import isprorower - + def do_sync(w,options): try: if options['stravaid'] != 0: @@ -524,20 +524,21 @@ def do_sync(w,options): if ('upload_to_Strava' in options and not options['upload_to_Strava']): pass else: - try: - message,id = stravastuff.workout_strava_upload( + if options['stravaid'] != 0: + try: + message,id = stravastuff.workout_strava_upload( w.user.user,w - ) - except NoTokenError: - id = 0 - message = "Please connect to Strava first" - + ) + 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 isprorower(w.user)): if ('upload_to_SportTracks' in options and not options['upload_to_SportTracks']): pass else: - + try: message,id = sporttracksstuff.workout_sporttracks_upload( w.user.user,w @@ -545,13 +546,13 @@ def do_sync(w,options): except NoTokenError: message = "Please connect to SportTracks first" id = 0 - - + + if ('upload_to_RunKeeper' in options and options['upload_to_RunKeeper']) or (w.user.runkeeper_auto_export and isprorower(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 @@ -559,11 +560,11 @@ def do_sync(w,options): 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 isprorower(w.user)): if ('upload_to_MapMyFitness' in options and not options['upload_to_MapMyFitness']): pass - else: + else: try: message,id = underarmourstuff.workout_ua_upload( w.user.user,w @@ -572,7 +573,7 @@ def do_sync(w,options): 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 isprorower(w.user)): if ('upload_to_TrainingPeaks' in options and not options['upload_to_TrainingPeaks']): pass