Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alan Marchiori
labtool
Commits
90aec70a
Commit
90aec70a
authored
Jan 28, 2020
by
Alan Marchiori
Browse files
bug fixes
parent
bade350e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
90aec70a
...
...
@@ -17,10 +17,10 @@ all: dist
dist
:
#
$(CC)
lt.c
-o
lt
-fno-lto
-fPIC
$(CFLAGS)
$(LDFLAGS)
$(LIBS)
rm
-rf
di
st
rm
-rf
st
age
./rev.py lt.py
chmod
go+rx lt.py
pyinstaller lt.py
chmod
-R
go+r
di
st
pyinstaller
--distpath
stage
lt.py
chmod
-R
go+r st
age
clean
:
rm
-fr
lt.c deploy lt
di
st lt.spec
rm
-fr
lt.c deploy lt st
age
lt.spec
commands/check.py
View file @
90aec70a
...
...
@@ -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
)
...
...
commands/checker.py
View file @
90aec70a
...
...
@@ -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
:
...
...
commands/grade.py
View file @
90aec70a
...
...
@@ -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)
...
...
lt.py
View file @
90aec70a
...
...
@@ -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-2
3T15:22:20.6415
22'
__date__
=
'2020-01-2
8T09:37:05.342
22
9
'
__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
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment