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
95eb2e32
Commit
95eb2e32
authored
Jan 05, 2021
by
Alan Marchiori
Browse files
added shell command
parent
25cb5ddf
Changes
3
Hide whitespace changes
Inline
Side-by-side
commands/__init__.py
View file @
95eb2e32
...
...
@@ -7,5 +7,6 @@ from .report import report
from
.menu
import
menu
from
.email
import
email
from
.db
import
db
from
.shell
import
shell
__all__
=
[
'userconfig'
,
'init'
,
'check'
,
'test'
,
'grade'
,
'report'
,
'menu'
,
'email'
,
'db'
]
'report'
,
'menu'
,
'email'
,
'db'
,
'shell'
]
commands/menu.py
View file @
95eb2e32
...
...
@@ -276,7 +276,7 @@ def menu(ctx):
command_list
=
HSplit
(
[
Button
(
text
=
cmd
,
handler
=
partial
(
do_cmd
,
ctx
,
cmd
,
projects
,
proj_list
,
lab_list
,
part_list
))
for
cmd
in
[
'grade'
,
'regrade'
,
'report'
,
'email'
]]
+
\
for
cmd
in
[
'grade'
,
'shell'
,
'regrade'
,
'report'
,
'email'
]]
+
\
[
Button
(
text
=
"exit"
,
handler
=
lambda
:
get_app
().
exit
(
result
=
False
))]
)
verstr
=
"Labtool v{}"
.
format
(
sys
.
modules
[
'__main__'
].
__version__
)
...
...
commands/shell.py
0 → 100644
View file @
95eb2e32
import
click
import
config
from
config.echo
import
*
import
courses
import
os
import
subprocess
@
click
.
command
()
@
click
.
option
(
'--lab'
,
type
=
int
,
required
=
True
,
help
=
'The lab (number).'
)
@
click
.
option
(
"--user"
,
default
=
None
,
required
=
True
,
help
=
'User dir to enter.'
)
def
shell
(
lab
,
user
,
**
kwargs
):
"Lauch a terminal shell in a student work directory."
# convert lab number to filename magic.
if
lab
:
labstr
=
"lab{:02}"
.
format
(
lab
)
else
:
labstr
=
None
coursename
,
coursepath
,
labname
,
ista
=
courses
.
detect_course
(
lab
=
labstr
)
if
not
coursename
:
error
(
"The current directory is not an initialized course! You must first cd into an initialized course!"
)
return
if
not
labname
:
error
(
"You must specify the lab number to enter (--lab #)"
)
return
if
not
user
:
error
(
"You must specify the user name to enter (--user USER)"
)
return
rubric
=
courses
.
load_rubric
(
coursename
,
labname
)
labpath
=
os
.
path
.
join
(
coursepath
,
user
,
rubric
[
'path'
])
subprocess
.
run
(
[
'/bin/bash'
],
cwd
=
labpath
,
env
=
os
.
environ
.
copy
()
)
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