Private
Public Access
1
0

Merge branch 'develop' into feature/stravaapi

This commit is contained in:
2024-12-11 21:45:08 +01:00
37 changed files with 5113 additions and 71 deletions

View File

@@ -130,11 +130,14 @@ def make_plot(r, w, f1, f2, plottype, title, imagename='', plotnr=0):
def do_sync(w, options, quick=False):
do_strava_export = w.user.strava_auto_export
try:
do_strava_export = options['upload_to_Strava'] or do_strava_export
except KeyError:
pass
do_strava_export = False
if w.user.strava_auto_export is True:
do_strava_export = True
else:
try:
do_strava_export = options['upload_to_Strava'] or do_strava_export
except KeyError:
pass
try:
if options['stravaid'] != 0 and options['stravaid'] != '': # pragma: no cover
@@ -150,6 +153,27 @@ def do_sync(w, options, quick=False):
except KeyError:
pass
do_icu_export = False
if w.user.intervals_auto_export is True:
do_icu_export = True
else:
try:
do_icu_export = options['upload_to_Intervals']
except KeyError:
pass
#dologging("uploads.log", "do_icu_export: {do_icu_export}".format(do_icu_export=do_icu_export))
try:
if options['intervalsid'] != 0 and options['intervalsid'] != '': # pragma: no cover
w.uploadedtointervals = options['intervalsid']
# upload_to_icu = False
do_icu_export = False
w.save()
record = create_or_update_syncrecord(w.user, w, intervalsid=options['intervalsid'])
except KeyError:
pass
try:
if options['nkid'] != 0 and options['nkid'] != '': # pragma: no cover
w.uploadedtonk = options['nkid']
@@ -181,11 +205,14 @@ def do_sync(w, options, quick=False):
except KeyError:
pass
do_c2_export = w.user.c2_auto_export
try:
do_c2_export = options['upload_to_C2'] or do_c2_export
except KeyError:
pass
do_c2_export = False
if w.user.c2_auto_export is True:
do_c2_export = True
else:
try:
do_c2_export = options['upload_to_C2'] or do_c2_export
except KeyError:
pass
try:
if options['c2id'] != 0 and options['c2id'] != '': # pragma: no cover
@@ -236,14 +263,30 @@ def do_sync(w, options, quick=False):
except NoTokenError: # pragma: no cover
id = 0
message = "Please connect to Strava first"
except:
e = sys.exc_info()[0]
t = time.localtime()
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
with open('stravalog.log', 'a') as f:
f.write('\n')
f.write(timestamp)
f.write(str(e))
except Exception as e:
dologging('stravalog.log', e)
if do_icu_export:
intervals_integration = IntervalsIntegration(w.user.user)
try:
id = intervals_integration.workout_export(w)
dologging(
'intervals.icu.log',
'exporting workout {id} as {type}'.format(
id=w.id,
type=w.workouttype,
)
)
except NoTokenError:
id = 0
dologging('intervals.icu.log','NoTokenError')
message = "Please connect to Intervals.icu first"
except Exception as e:
dologging(
'intervals.icu.log',
e
)
do_st_export = w.user.sporttracks_auto_export