logging for tp export
This commit is contained in:
@@ -231,34 +231,48 @@ def do_sync(w, options, quick=False):
|
||||
f.write(timestamp)
|
||||
f.write(str(e))
|
||||
|
||||
do_tp_export = w.user.trainingpeaks_auto_export
|
||||
do_st_export = w.user.sporttracks_auto_export
|
||||
try: # pragma: no cover
|
||||
upload_to_tp = options['upload_to_SportTracks'] or do_tp_export
|
||||
do_tp_export = upload_to_tp
|
||||
upload_to_st = options['upload_to_SportTracks'] or do_st_export
|
||||
do_st_export = upload_to_st
|
||||
except KeyError:
|
||||
upload_to_tp = False
|
||||
upload_to_st = False
|
||||
|
||||
if do_tp_export: # pragma: no cover
|
||||
if do_st_export: # pragma: no cover
|
||||
try:
|
||||
message, id = sporttracksstuff.workout_sporttracks_upload(
|
||||
w.user.user, w, asynchron=True,
|
||||
)
|
||||
with open('st_export.log', 'a') as logfile: # pragma: no cover
|
||||
logfile.write(str(timezone.now())+': ')
|
||||
logfile.write('Workout uploaded '+str(w.id)+'\n')
|
||||
dologging('st_export.log',
|
||||
'exported workout {wid} for user {uid}'.format(
|
||||
wid = w.id,
|
||||
uid = w.user.user.id,
|
||||
)
|
||||
)
|
||||
except NoTokenError:
|
||||
with open('st_export.log', 'a') as logfile:
|
||||
logfile.write(str(timezone.now())+': ')
|
||||
logfile.write(str(w.user)+' NoTokenError\n')
|
||||
dologging('st_export.log','No Token Error')
|
||||
|
||||
return 0
|
||||
|
||||
if ('upload_to_TrainingPeaks' in options and options['upload_to_TrainingPeaks']) or (w.user.trainingpeaks_auto_export): # pragma: no cover
|
||||
do_tp_export = w.user.trainingpeaks_auto_export
|
||||
try:
|
||||
upload_to_tp = options['upload_to_TrainingPeaks'] or do_tp_export
|
||||
do_tp_export = upload_to_tp
|
||||
except KeyError:
|
||||
upload_to_st = False
|
||||
if do_tp_export:
|
||||
try:
|
||||
_, id = tpstuff.workout_tp_upload(
|
||||
w.user.user, w
|
||||
)
|
||||
dologging('tp_export.log',
|
||||
'exported workout {wid} for user {uid}'.format(
|
||||
wid = w.id,
|
||||
uid = w.user.user.id,
|
||||
)
|
||||
)
|
||||
except NoTokenError:
|
||||
dologging('tp_export.log','No Token Error')
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user