Private
Public Access
1
0

passing some tests on py3, all on py2

This commit is contained in:
Sander Roosendaal
2019-02-25 21:03:30 +01:00
parent 199382a700
commit 617f1e5d9f
13 changed files with 56 additions and 606 deletions

View File

@@ -2106,7 +2106,7 @@ def virtualevent_submit_result_view(request,id=0,workoutid=0):
entrychoices = []
for record in records:
rtpl = (record.id, record.__unicode__())
rtpl = (record.id, record.__str__())
entrychoices.append(rtpl)
entries = {}
@@ -2153,7 +2153,7 @@ def virtualevent_submit_result_view(request,id=0,workoutid=0):
choices = []
for w in ws:
wtpl = (w.id, w.__unicode__())
wtpl = (w.id, w.__str__())
choices.append(wtpl)
if w.id in initialworkouts:
workoutdata['initial'].append(w.id)

View File

@@ -726,7 +726,10 @@ def get_stored_tasks_status(request):
taskstatus = []
for id,func_name in reversed(taskids):
progress = 0
cached_progress = cache.get(id)
try:
cached_progress = cache.get(id)
except ValueError:
cached_progress = 0
finished = get_job_status(id)['finished']
if finished:
cache.set(id,100)

View File

@@ -874,7 +874,7 @@ def virtualevent_compare_view(request,id=0):
pass
labeldict = {
int(w.id): w.__unicode__() for w in workouts
int(w.id): w.__str__() for w in workouts
}
chartform = ChartParamChoiceForm(
@@ -906,7 +906,7 @@ def virtualevent_compare_view(request,id=0):
pass
labeldict = {
int(w.id): w.__unicode__() for w in workouts
int(w.id): w.__str__() for w in workouts
}
else:
raise HttpResponse('Only GET and POST allowed',status=405)
@@ -988,7 +988,7 @@ def plannedsession_compare_view(request,id=0,userid=0):
ids = [int(w.id) for w in workouts]
labeldict = {
int(w.id): w.__unicode__() for w in workouts
int(w.id): w.__str__() for w in workouts
}
xparam = 'time'
@@ -1033,7 +1033,7 @@ def multi_compare_view(request,id=0,userid=0):
request.session['ids'] = ids
labeldict = {
int(w.id): w.__unicode__() for w in workouts
int(w.id): w.__str__() for w in workouts
}
else:
@@ -1055,7 +1055,7 @@ def multi_compare_view(request,id=0,userid=0):
pass
labeldict = {
int(w.id): w.__unicode__() for w in workouts
int(w.id): w.__str__() for w in workouts
}
elif 'ids' in request.session and 'plottype' in request.session:
xparam = request.session['xparam']
@@ -1071,7 +1071,7 @@ def multi_compare_view(request,id=0,userid=0):
pass
labeldict = {
int(w.id): w.__unicode__() for w in workouts
int(w.id): w.__str__() for w in workouts
}
chartform = ChartParamChoiceForm(
initial = {
@@ -2510,7 +2510,7 @@ def workout_stats_view(request,id=0,message="",successmessage=""):
fielddict.pop('workoutstate')
fielddict.pop('workoutid')
for field,verbosename in fielddict.iteritems():
for field,verbosename in fielddict.items():
thedict = {
'mean':datadf[field].mean(),
'wmean': wavg(datadf, field, 'deltat'),
@@ -2528,9 +2528,9 @@ def workout_stats_view(request,id=0,message="",successmessage=""):
cor = datadf.corr(method='spearman')
cor.fillna(value=0,inplace=True)
cordict = {}
for field1,verbosename in fielddict.iteritems():
for field1,verbosename in fielddict.items():
thedict = {}
for field2,verbosename in fielddict.iteritems():
for field2,verbosename in fielddict.items():
try:
thedict[field2] = cor.loc[field1,field2]
except KeyError:
@@ -3211,10 +3211,14 @@ def workout_comment_view(request,id=0):
cd = form.cleaned_data
comment = cd['comment']
comment = bleach.clean(comment)
if isinstance(comment,unicode):
comment = comment.encode('utf8')
elif isinstance(comment, str):
comment = comment.decode('utf8')
try:
if isinstance(comment,unicode):
comment = comment.encode('utf8')
elif isinstance(comment, str):
comment = comment.decode('utf8')
except:
pass
notification = cd['notification']
c = WorkoutComment(workout=w,user=request.user,comment=comment,
@@ -4978,7 +4982,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
iunits = []
itypes = []
iresults = []
for i in xrange(nrintervals):
for i in range(nrintervals):
try:
t = datetime.datetime.strptime(request.POST['intervalt_%s' % i],"%H:%M:%S.%f")
except ValueError:
@@ -5042,7 +5046,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
iunits = []
itypes = []
iresults = []
for i in xrange(nrintervals):
for i in range(nrintervals):
t = cd['intervalt_%s' % i]
timesecs = t.total_seconds()
itime += [timesecs]
@@ -5076,7 +5080,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
initial = {}
for i in xrange(nrintervals):
for i in range(nrintervals):
try:
initial['intervald_%s' % i] = idist[i]
initial['intervalt_%s' % i] = get_time(itime[i])