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

added does_not_contain

parent 1ebd3a80
......@@ -25,29 +25,7 @@ def show_report(hist, partstr, info):
width = min(120, shutil.get_terminal_size().columns)
#if 'grade' in info:
newline()
xlen = 47 # length of everything without name
echo("Part {:3}: {}".format(
info['index'],
info['name'][:max(10,width-xlen)].ljust(width-xlen)
))
echo(info['prompt'])
if partstr in hist['grade']:
echo('\tGrade: {} of {}'.format(
hist['grade'][partstr]['grade'],
hist['grade'][partstr]['total']))
if hist['grade'][partstr]['comment'] != '':
echo('\tComment: {}'.format(
hist['grade'][partstr]['comment']))
else:
warn("Part {:3} is ungraded ({})!".format(
info['index'], partstr
))
if 'TOTAL' in hist['grade']:
if partstr == 'TOTAL':
newline()
echo("-"*width)
newline()
......@@ -58,6 +36,39 @@ def show_report(hist, partstr, info):
echo("Graded by {}".format(
hist['grade']['TOTAL']['who']
))
else:
newline()
xlen = 47 # length of everything without name
echo("Part {:3}: {}".format(
info['index'],
info['name'][:max(10,width-xlen)].ljust(width-xlen)
))
echo(info['prompt'])
if partstr in hist['grade']:
echo('\tGrade: {} of {}'.format(
hist['grade'][partstr]['grade'],
hist['grade'][partstr]['total']))
if hist['grade'][partstr]['comment'] != '':
echo('\tComment: {}'.format(
hist['grade'][partstr]['comment']))
else:
warn("Part {:3} is ungraded ({})!".format(
info['index'], partstr
))
#
# if 'TOTAL' in hist['grade']:
# newline()
# echo("-"*width)
# newline()
# echo("Total: {} of {}".format(
# hist['grade']['TOTAL']['grade'],
# hist['grade']['TOTAL']['total']
# ))
# echo("Graded by {}".format(
# hist['grade']['TOTAL']['who']
# ))
@click.command(short_help="Check LAB")
@click.option('--lab', type=int, default=None)
......@@ -150,6 +161,10 @@ def check(lab, part):
# stop checking on first part failure
break
# show total grade at the end, if it's graded.
if 'grade' in hist and 'TOTAL' in hist['grade']:
show_report(hist, 'TOTAL', None)
# only check gitlab if all tests pass
if all(presults):
newline()
......
......@@ -105,6 +105,10 @@ class Checker:
else:
error("{}: failed!".format(msg))
error(t)
if 'on_error' in check:
error(check['on_error'])
# stop on first error
return False
if 'stdout' in check:
......@@ -198,16 +202,41 @@ class Checker:
result = []
for test in args:
for fname, check in test.items():
text = Path(fname).read_text()
for c in check:
a = c in text
result += [a]
if not a:
warn("The file {} does not contain \"{}\"".format(
fname, c
))
if os.path.exists(fname):
text = Path(fname).read_text()
for c in check:
a = c in text
result += [a]
if not a:
warn("The file {} does not contain \"{}\"".format(
fname, c
))
else:
warn("The file {} does not exist!".format(fname))
result += [False]
return all(result)
def does_not_contain(self, args):
"list of file: words to check for... returns true if all words are not found"
dbg('.does_not_contain({})'.format(args))
result = []
for test in args:
for fname, check in test.items():
if os.path.exists(fname):
text = Path(fname).read_text()
for c in check:
a = c in text
result += [a]
if a:
warn("The file {} contains \"{}\"".format(
fname, c
))
else:
warn("The file {} does not exist!".format(fname))
result += [False]
return not any(result)
def cd_labroot(self):
if os.path.exists(self.cwd):
debug("{}: {}".format(__name__,
......@@ -245,7 +274,7 @@ class Checker:
# 'show']: # show is used for grading
# continue
for i,subpart in enumerate(self.info[check_type]):
for k, args in subpart.items():
debug(k, args)
if hasattr(self, k):
......
......@@ -211,9 +211,14 @@ def init(course, semester, section, prefix, ta):
# success(src)
if '.gitignore' in coursedef:
if os.path.exists(os.expanduser(coursedef['.gitignore'])):
shutil.copyfile(os.expanduser(coursedef['.gitignore']),
lp)
if os.path.exists(os.path.expanduser(coursedef['.gitignore'])):
src = os.path.expanduser(coursedef['.gitignore'])
dst = os.path.join(lp, '.gitignore')
debug("COPY {} --> {}".format(
src,
dst
))
shutil.copyfile(src, dst)
git.do_push(addfiles=['.gitignore'],
cwd=lp, message='Added by labtool')
else:
......
......@@ -35,7 +35,7 @@ smtp_handler = logging.handlers.SMTPHandler(
subject=u"labtool crash report!")
__version__ = '1.0.3'
__date__ = '2020-01-20T12:25:27.481510'
__date__ = '2020-01-23T15:22:20.641522'
__user__ = 'cs206'
__host__ = 'linuxremote3.bucknell.edu'
@click.group()
......
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