Commit a76118e4 authored by Alan Marchiori's avatar Alan Marchiori
Browse files

fixed history json error detection

parent 9492c479
......@@ -54,7 +54,7 @@ def ta_report(coursename, coursepath, labname, user, clone):
report_parts = ["{}, {}".format(
"student".ljust(8),
", ".join(
["L{}p, L{}t".format(ln[3:5], ln[3:5]) for ln in labnames]))]
["L{}pt, L{}t".format(ln[3:5], ln[3:5]) for ln in labnames]))]
print(", ".join(report_parts))
c_tot = defaultdict(list)
......@@ -91,11 +91,13 @@ def ta_report(coursename, coursepath, labname, user, clone):
if 'TOTAL' in r:
c_tot[labname].append(r['TOTAL']['grade'])
report_parts += [str(r['TOTAL']['grade']).ljust(4), str(r['TOTAL']['total']).ljust(4)]
report_parts += [str(r['TOTAL']['grade']).rjust(5), str(r['TOTAL']['total']).rjust(5)]
else:
report_parts += [' ', ' ']
debug ("no total in grade")
report_parts += [' ', ' ']
else:
report_parts += [' ', ' ']
debug ("no grade in history")
report_parts += [' ', ' ']
print(", ".join(report_parts))
......@@ -104,7 +106,7 @@ def ta_report(coursename, coursepath, labname, user, clone):
labname = rub['name']
if len(c_tot[labname]) > 0:
report_parts += [
"{:4.1f}, {:4.1f}".format(
"{:5.1f}, {:5.1f}".format(
np.mean(c_tot[labname]),
np.std(c_tot[labname])),
]
......
......@@ -35,8 +35,8 @@ smtp_handler = logging.handlers.SMTPHandler(
toaddrs=config.crash_reports,
subject=u"labtool crash report!")
__version__ = '1.0.7'
__date__ = '2020-02-06T09:14:17.511052'
__version__ = '1.0.9'
__date__ = '2020-02-11T12:03:51.878974'
__user__ = 'cs206'
__host__ = 'linuxremote3.bucknell.edu'
@click.group()
......
import os
import os.path
import json
from config.echo import debug
from config.echo import debug, error
class History(dict):
"""A simple class to store grade history.
......@@ -40,7 +40,12 @@ class History(dict):
try:
with open(self.pathfile, 'r') as f:
self.rawjson = f.read()
self.update(json.loads(self.rawjson))
try:
d = json.loads(self.rawjson)
except json.decoder.JSONDecodeError:
error("Grading history file at {} is corrupt. Manually remove or fix this file to continue running.".format(self.pathfile))
exit(212)
self.update(d)
except Exception as x:
print(x)
exit()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment