Private
Public Access
1
0

adding extra log

This commit is contained in:
Sander Roosendaal
2020-07-07 17:43:45 +02:00
parent 30a3602774
commit 001cf55591
3 changed files with 23 additions and 28 deletions

View File

@@ -41,7 +41,7 @@ def time_in_path(df,p,maxmin='max',getall=False,name='unknown',logfile=None):
if logfile is not None:
t = time.localtime()
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
with open(logfile,'a') as f:
with open(logfile,'ab') as f:
f.write('\n')
f.write(timestamp)
f.write(' ')
@@ -65,7 +65,7 @@ def time_in_path(df,p,maxmin='max',getall=False,name='unknown',logfile=None):
if logfile is not None:
t = time.localtime()
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
with open(logfile,'a') as f:
with open(logfile,'ab') as f:
f.write('\n')
f.write(timestamp)
f.write(' ')

View File

@@ -198,7 +198,7 @@ def handle_strava_sync(stravatoken,workoutid,filename,name,activity_type,descrip
e = sys.exc_info()[0]
t = time.localtime()
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
with open('stravalog.log','a') as f:
with open('stravalog.log','ab') as f:
f.write('\n')
f.write(timestamp)
f.write(str(e))
@@ -446,7 +446,7 @@ def handle_check_race_course(self,
try:
entrytimes,entrydistances = time_in_path(rowdata,paths[0],maxmin='max',getall=True,
name=polygons[0].name,logfile=logfile)
with open(logfile,'a') as f:
with open(logfile,'ab') as f:
t = time.localtime()
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
f.write('\n')
@@ -471,7 +471,7 @@ def handle_check_race_course(self,
endseconds = []
for startt in entrytimes:
with open(logfile,'a') as f:
with open(logfile,'ab') as f:
t = time.localtime()
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
f.write('\n')
@@ -594,17 +594,19 @@ def handle_check_race_course(self,
engine.dispose()
# add times for all gates to log file
with open(logfile,'a') as f:
with open(logfile,'ab') as f:
t = time.localtime()
f.write('\n')
f.write(timestamp)
f.write(' ')
f.write('--- LOG of all gate times---')
for path,polygon in (paths,polygons):
for path,polygon in zip(paths,polygons):
( secs,meters,completed) = coursetime_paths(rowdata2,
[path],[polygon],logfile=logfile)
[path],polygons=[polygon],logfile=logfile)
with open(logfile,'ab') as f:
line = " time: {t} seconds, distance: {m} meters".format(t=secs,m=meters)
f.write(line)
# send email
handle_sendemail_coursefail(

View File

@@ -1036,26 +1036,19 @@ def garmin_deregistration_view(request):
if request.method != 'POST':
return HttpResponse(status=200)
t = time.localtime()
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
with open('garminlog.log','a') as f:
f.write('\n')
f.write(timestamp)
f.write(' ')
f.write(str(request.body))
data = json.loads(request.body)
try:
garmintoken = data['userAccessToken']
except KeyError:
print(data)
return HttpResponse(status=200)
try:
r = Rower.objects.get(garmintoken=garmintoken)
r.garmintoken = ''
r.save()
except Rower.DoesNotExist:
return HttpResponse(status=200)
deregistrations = data['deregistrations']
for deregistration in deregistrations:
try:
garmintoken = deregistration['userAccessToken']
try:
r = Rower.objects.get(garmintoken=garmintoken)
r.garmintoken = ''
r.save()
except Rower.DoesNotExist:
pass
except KeyError:
pass
return HttpResponse(status=200)