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

added does_not_contain

parent 1ebd3a80
...@@ -25,7 +25,18 @@ def show_report(hist, partstr, info): ...@@ -25,7 +25,18 @@ def show_report(hist, partstr, info):
width = min(120, shutil.get_terminal_size().columns) width = min(120, shutil.get_terminal_size().columns)
#if 'grade' in info: if partstr == 'TOTAL':
newline()
echo("-"*width)
newline()
echo("Total: {} of {}".format(
hist['grade']['TOTAL']['grade'],
hist['grade']['TOTAL']['total']
))
echo("Graded by {}".format(
hist['grade']['TOTAL']['who']
))
else:
newline() newline()
xlen = 47 # length of everything without name xlen = 47 # length of everything without name
echo("Part {:3}: {}".format( echo("Part {:3}: {}".format(
...@@ -46,18 +57,18 @@ def show_report(hist, partstr, info): ...@@ -46,18 +57,18 @@ def show_report(hist, partstr, info):
warn("Part {:3} is ungraded ({})!".format( warn("Part {:3} is ungraded ({})!".format(
info['index'], partstr info['index'], partstr
)) ))
#
if 'TOTAL' in hist['grade']: # if 'TOTAL' in hist['grade']:
newline() # newline()
echo("-"*width) # echo("-"*width)
newline() # newline()
echo("Total: {} of {}".format( # echo("Total: {} of {}".format(
hist['grade']['TOTAL']['grade'], # hist['grade']['TOTAL']['grade'],
hist['grade']['TOTAL']['total'] # hist['grade']['TOTAL']['total']
)) # ))
echo("Graded by {}".format( # echo("Graded by {}".format(
hist['grade']['TOTAL']['who'] # hist['grade']['TOTAL']['who']
)) # ))
@click.command(short_help="Check LAB") @click.command(short_help="Check LAB")
@click.option('--lab', type=int, default=None) @click.option('--lab', type=int, default=None)
...@@ -150,6 +161,10 @@ def check(lab, part): ...@@ -150,6 +161,10 @@ def check(lab, part):
# stop checking on first part failure # stop checking on first part failure
break 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 # only check gitlab if all tests pass
if all(presults): if all(presults):
newline() newline()
......
...@@ -105,6 +105,10 @@ class Checker: ...@@ -105,6 +105,10 @@ class Checker:
else: else:
error("{}: failed!".format(msg)) error("{}: failed!".format(msg))
error(t) error(t)
if 'on_error' in check:
error(check['on_error'])
# stop on first error # stop on first error
return False return False
if 'stdout' in check: if 'stdout' in check:
...@@ -198,6 +202,7 @@ class Checker: ...@@ -198,6 +202,7 @@ class Checker:
result = [] result = []
for test in args: for test in args:
for fname, check in test.items(): for fname, check in test.items():
if os.path.exists(fname):
text = Path(fname).read_text() text = Path(fname).read_text()
for c in check: for c in check:
a = c in text a = c in text
...@@ -206,8 +211,32 @@ class Checker: ...@@ -206,8 +211,32 @@ class Checker:
warn("The file {} does not contain \"{}\"".format( warn("The file {} does not contain \"{}\"".format(
fname, c fname, c
)) ))
else:
warn("The file {} does not exist!".format(fname))
result += [False]
return all(result) 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): def cd_labroot(self):
if os.path.exists(self.cwd): if os.path.exists(self.cwd):
debug("{}: {}".format(__name__, debug("{}: {}".format(__name__,
......
...@@ -211,9 +211,14 @@ def init(course, semester, section, prefix, ta): ...@@ -211,9 +211,14 @@ def init(course, semester, section, prefix, ta):
# success(src) # success(src)
if '.gitignore' in coursedef: if '.gitignore' in coursedef:
if os.path.exists(os.expanduser(coursedef['.gitignore'])): if os.path.exists(os.path.expanduser(coursedef['.gitignore'])):
shutil.copyfile(os.expanduser(coursedef['.gitignore']), src = os.path.expanduser(coursedef['.gitignore'])
lp) dst = os.path.join(lp, '.gitignore')
debug("COPY {} --> {}".format(
src,
dst
))
shutil.copyfile(src, dst)
git.do_push(addfiles=['.gitignore'], git.do_push(addfiles=['.gitignore'],
cwd=lp, message='Added by labtool') cwd=lp, message='Added by labtool')
else: else:
......
...@@ -35,7 +35,7 @@ smtp_handler = logging.handlers.SMTPHandler( ...@@ -35,7 +35,7 @@ smtp_handler = logging.handlers.SMTPHandler(
subject=u"labtool crash report!") subject=u"labtool crash report!")
__version__ = '1.0.3' __version__ = '1.0.3'
__date__ = '2020-01-20T12:25:27.481510' __date__ = '2020-01-23T15:22:20.641522'
__user__ = 'cs206' __user__ = 'cs206'
__host__ = 'linuxremote3.bucknell.edu' __host__ = 'linuxremote3.bucknell.edu'
@click.group() @click.group()
......
Supports Markdown
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