adding logging and fixing course evaluation
This commit is contained in:
@@ -939,6 +939,8 @@ def handle_check_race_course(self,
|
||||
|
||||
logfile = 'courselog_{workoutid}_{courseid}.log'.format(
|
||||
workoutid=workoutid, courseid=courseid)
|
||||
logfile2 = 'courses.log'
|
||||
dologging(logfile2,logfile)
|
||||
|
||||
if 'debug' in kwargs: # pragma: no cover
|
||||
debug = kwargs['debug']
|
||||
@@ -981,6 +983,8 @@ def handle_check_race_course(self,
|
||||
try:
|
||||
row = rdata(csvfile=f1 + '.gz')
|
||||
except IOError: # pragma: no cover
|
||||
dologging(logfile,"Did not find file "+f1)
|
||||
dologging(logfile2,"Did not find file "+f1)
|
||||
return 0
|
||||
|
||||
row.extend_data()
|
||||
@@ -994,6 +998,8 @@ def handle_check_race_course(self,
|
||||
try:
|
||||
_ = rowdata[' latitude']
|
||||
except KeyError: # pragma: no cover
|
||||
dologging(logfile,"No GPS Data")
|
||||
dologging(logfile2,"No GPS Data")
|
||||
return 0
|
||||
|
||||
rowdata.rename(columns={
|
||||
@@ -1012,7 +1018,7 @@ def handle_check_race_course(self,
|
||||
lambda x: safetimedelta(x)
|
||||
).values
|
||||
|
||||
|
||||
rowdata = rowdata.select_types(['number'])
|
||||
rowdata = rowdata.resample('100ms', on='dt').mean()
|
||||
rowdata = rowdata.interpolate()
|
||||
|
||||
@@ -1036,18 +1042,12 @@ def handle_check_race_course(self,
|
||||
except AttributeError: # pragma: no cover
|
||||
entrytimes, entrydistances = time_in_path(rowdata, paths[0], maxmin='max', getall=True,
|
||||
name='Start', logfile=logfile)
|
||||
with open(logfile, 'ab') as f:
|
||||
t = time.localtime()
|
||||
timestamp = bytes('{t}'.format(
|
||||
t=time.strftime('%b-%d-%Y_%H%M', t)), 'utf-8')
|
||||
f.write(b'\n')
|
||||
f.write(bytes('Course id {n}, Record id {m}'.format(
|
||||
n=courseid, m=recordid), 'utf-8'))
|
||||
f.write(b'\n')
|
||||
f.write(timestamp)
|
||||
f.write(b' ')
|
||||
f.write(bytes('Found {n} entrytimes'.format(
|
||||
n=len(entrytimes)), 'utf-8'))
|
||||
logmessage = 'Course id {n}, Record id {m}'.format(n=courseid, m=recordid)
|
||||
dologging(logfile,logmessage)
|
||||
dologging(logfile2,logmessage)
|
||||
logmessage = 'Found {n} entrytimes'.format(n=len(entrytimes))
|
||||
dologging(logfile,logmessage)
|
||||
dologging(logfile2,logmessage)
|
||||
|
||||
except InvalidTrajectoryError: # pragma: no cover
|
||||
entrytimes = []
|
||||
@@ -1062,14 +1062,9 @@ def handle_check_race_course(self,
|
||||
endseconds = []
|
||||
|
||||
for startt in entrytimes:
|
||||
with open(logfile, 'ab') as f:
|
||||
t = time.localtime()
|
||||
timestamp = bytes('{t}'.format(
|
||||
t=time.strftime('%b-%d-%Y_%H%M', t)), 'utf-8')
|
||||
f.write(b'\n')
|
||||
f.write(timestamp)
|
||||
f.write(b' ')
|
||||
f.write(bytes('Path starting at {t}'.format(t=startt), 'utf-8'))
|
||||
logmessage = 'Path starting at {t}'.format(t=startt)
|
||||
dologging(logfile, logmessage)
|
||||
dologging(logfile2, logmessage)
|
||||
rowdata2 = rowdata[rowdata['time'] > (startt-10.)]
|
||||
|
||||
(
|
||||
@@ -1102,7 +1097,6 @@ def handle_check_race_course(self,
|
||||
'endsecond': endseconds,
|
||||
})
|
||||
|
||||
#records = records[records['coursecompleted'] is True]
|
||||
records = records.loc[records['coursecompleted'], : ]
|
||||
|
||||
if len(records):
|
||||
@@ -1200,19 +1194,15 @@ def handle_check_race_course(self,
|
||||
|
||||
|
||||
# add times for all gates to log file
|
||||
with open(logfile, 'ab') as f:
|
||||
t = time.localtime()
|
||||
f.write(b'\n')
|
||||
f.write(b' ')
|
||||
f.write(b'--- LOG of all gate times---')
|
||||
dologging(logfile,'--- LOG of all gate times---')
|
||||
dologging(logfile2,'--- LOG of all gate times---')
|
||||
|
||||
for path, polygon in zip(paths, polygons):
|
||||
(secs, meters, completed) = coursetime_paths(rowdata,
|
||||
[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(bytes(line, 'utf-8'))
|
||||
logmessage = " time: {t} seconds, distance: {m} meters".format(t=secs, m=meters)
|
||||
dologging(logfile,logmessage)
|
||||
dologging(logfile2,logmessage)
|
||||
|
||||
# send email
|
||||
handle_sendemail_coursefail(
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
Reference in New Issue
Block a user