Commit 90aec70a authored by Alan Marchiori's avatar Alan Marchiori
Browse files

bug fixes

parent bade350e
......@@ -17,10 +17,10 @@ all: dist
dist:
#$(CC) lt.c -o lt -fno-lto -fPIC $(CFLAGS) $(LDFLAGS) $(LIBS)
rm -rf dist
rm -rf stage
./rev.py lt.py
chmod go+rx lt.py
pyinstaller lt.py
chmod -R go+r dist
pyinstaller --distpath stage lt.py
chmod -R go+r stage
clean:
rm -fr lt.c deploy lt dist lt.spec
rm -fr lt.c deploy lt stage lt.spec
......@@ -135,7 +135,10 @@ def check(lab, part):
if 'check' in info:
if 'check' in hist and partstr in hist['check']:
presults += hist['check'][partstr]['result']
# print("partstr: {}".format(partstr))
# print("pr: {}".format(presults))
# print("hi: {}".format(hist['check'][partstr]['result']))
presults += [hist['check'][partstr]['result']]
else:
c = Checker(info, labpath)
......
......@@ -91,6 +91,10 @@ class Checker:
))
try:
c,t = run(cmd, shell=sh, input=instr, timeout=to)
except OSError as oserr:
error("running $ {}: returned error: {}".format(
cmd, oserr
))
except subprocess.TimeoutExpired:
error("{}: Command timeout!".format(cmd))
c = -1
......@@ -103,7 +107,7 @@ class Checker:
if results[-1]:
success("{}: success.".format(msg))
else:
error("{}: failed!".format(msg))
error("{}: failed! Expected return code {} but got {}.".format(msg, check['returncode'], c))
error(t)
if 'on_error' in check:
......
......@@ -34,7 +34,9 @@ import contextlib # to redirect stdout
help='Set to only grade a single user (by git username).\t[default: ALL]')
@click.option("--feedback", default="feedback.txt",
help='File to write feedback to.')
def grade(lab, part, clone, dograde, regrade, user, feedback):
@click.option("--push/--no-push", default = True, show_default=True,
help='Push commits to gitlab?')
def grade(lab, part, clone, dograde, regrade, user, feedback, push):
"""grade LAB and PART for students from gitlab. LAB is required. If PART is omitted, ALL parts are graded.
"""
......@@ -220,7 +222,7 @@ def grade(lab, part, clone, dograde, regrade, user, feedback):
grade = hist['grade'][partstr]['grade']
if 'comment' in hist['grade'][partstr]:
grade_msg = hist['grade'][partstr]['comment']
c = Checker(info,
labpath,
remotepath=rubric['path'],
......@@ -276,24 +278,27 @@ def grade(lab, part, clone, dograde, regrade, user, feedback):
# if not g.clean(cwd=labpath) or g.file_diff(cwd=labpath,
# files=[hfile]):
# only check if the history file has changes. we won't automatically
# push any other files!
if g.file_diff(cwd=labpath, files=[hfile]):
g.do_push(cwd = labpath,
addfiles = [hfile],
message = 'Lab {} graded by {}'.format(
lab,
who
))
if not g.clean(cwd=labpath):
echo(g.status(cwd=labpath))
if confirm("The working directory is not clean, do you want to add & push ALL changes?"):
g.do_push(cwd=labpath, addall=True,
if push:
# only check if the history file has changes. we won't automatically
# push any other files!
if g.file_diff(cwd=labpath, files=[hfile]):
g.do_push(cwd = labpath,
addfiles = [hfile],
message = 'Lab {} graded by {}'.format(
lab,
who
))
if not g.clean(cwd=labpath):
echo(g.status(cwd=labpath))
if confirm("The working directory is not clean, do you want to add & push ALL changes?"):
g.do_push(cwd=labpath, addall=True,
message = 'Lab {} graded by {}'.format(
lab,
who
))
else:
warn("Not pushing to gitlab by your command.")
# fb_filename = os.path.join(labpath, feedback)
# feedbackfile = Path(fb_filename)
# feedbackfile.write_text(report)
......
......@@ -27,6 +27,7 @@ import logging
import logging.handlers
import os
import platform
import sys
smtp_handler = logging.handlers.SMTPHandler(
mailhost=("smtp.bucknell.edu", 25),
......@@ -35,7 +36,7 @@ smtp_handler = logging.handlers.SMTPHandler(
subject=u"labtool crash report!")
__version__ = '1.0.3'
__date__ = '2020-01-23T15:22:20.641522'
__date__ = '2020-01-28T09:37:05.342229'
__user__ = 'cs206'
__host__ = 'linuxremote3.bucknell.edu'
@click.group()
......@@ -75,9 +76,18 @@ if __name__ =="__main__":
error("Oops--Something went wrong in labtool ({}).".format(str(x)))
if 'show_exc' in uc.cfg:
error('{}@{}: Unhanded exception (cwd={}, cmd={})'.format(
os.environ['USER'],
platform.node(),
os.getcwd(),
sys.argv
))
traceback.print_exc()
else:
logger.exception('{}@{}: Unhanded exception.'.format(
logger.exception('{}@{}: Unhanded exception (cwd={}, cmd={})'.format(
os.environ['USER'],
platform.node()
platform.node(),
os.getcwd(),
sys.argv
))
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