Commit 95eb2e32 authored by Alan Marchiori's avatar Alan Marchiori
Browse files

added shell command

parent 25cb5ddf
......@@ -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']
......@@ -276,7 +276,7 @@ def menu(ctx):
command_list = HSplit(
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__)
import click
import config
from config.echo import *
import courses
import os
import subprocess
@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)
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!")
if not labname:
error("You must specify the lab number to enter (--lab #)")
if not user:
error("You must specify the user name to enter (--user USER)")
rubric = courses.load_rubric(coursename, labname)
labpath = os.path.join(coursepath, user, rubric['path'])
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