Commit 5f37389d authored by Alan Marchiori's avatar Alan Marchiori
Browse files

daily

parent e8a7d412
......@@ -2,8 +2,8 @@ CYTHON=cython
CPYFLAGS=-3 --embed
CC=gcc
#CFLAGS=`python3-config --cflags`
CFLAGS=-I/nfs/software/anaconda-3.7/include/python3.7m -I/nfs/software/anaconda-3.7/include/python3.7m -Wno-unused-result -Wsign-compare -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -O3 -ffunction-sections -pipe -fdebug-prefix-map=/tmp/build/80754af9/python_1553721932202/work=/usr/local/src/conda/python-3.7.3 -fdebug-prefix-map=/nfs/software/anaconda-3.7=/usr/local/src/conda-prefix -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -flto -DNDEBUG -fwrapv -O3 -Wall
CFLAGS=`python3-config --cflags`
# CFLAGS=-I/nfs/software/anaconda-3.7/include/python3.7m -I/nfs/software/anaconda-3.7/include/python3.7m -Wno-unused-result -Wsign-compare -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -O3 -ffunction-sections -pipe -fdebug-prefix-map=/tmp/build/80754af9/python_1553721932202/work=/usr/local/src/conda/python-3.7.3 -fdebug-prefix-map=/nfs/software/anaconda-3.7=/usr/local/src/conda-prefix -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -flto -DNDEBUG -fwrapv -O3 -Wall
LDFLAGS=`python3-config --ldflags`
LIBS=
......
from .init import init
from .check import check
from .userconfig import userconfig
__all__ = ['userconfig', 'init', 'check']
from .test import test
__all__ = ['userconfig', 'init', 'check', 'test']
......@@ -6,11 +6,11 @@ from config import UserConfig
from pprint import pprint
@click.command(short_help="Check LAB_NUMBER (e.g. \"lt check lab1\")")
@click.command(short_help="Check LAB_NUMBER (e.g. \"lt check lab01\")")
@click.argument('lab_number')
def check(lab_number):
"""check LAB_NUMBER without submitting, format as the string
"lab" plus a number (no spaces!), like "lab1" or "lab10".
"lab" plus a number (no spaces!), like "lab01" or "lab10".
"""
coursename, coursepath = courses.detect_course()
......@@ -28,4 +28,12 @@ def check(lab_number):
))
return
pprint(rubric)
for part, info in rubric['parts'].items():
if info['check']:
if do_check(coursepath, info):
success(info['name'])
else:
error(info['name'])
#pprint(rubric)
import click
import config
from config.echo import *
import courses
from config import UserConfig
from utils.gitlab import GitLab
from pprint import pprint
@click.command(short_help="Test labtool")
def test():
"Test the labtool installation and print some diagnostic information."
success("Labtool works!")
uc = UserConfig.getConfig()
echo("Your initialized courses: {}".format(
list(uc['courses'].keys())
))
echo("All available courses: {}".format(
list(courses.all.keys())
))
gl = GitLab()
if not 'api_token' in uc:
warn("You have not yet loaded your Gitlab API token.")
else:
if gl.check_token():
success("Gitlab token {} is valid.".format(uc['api_token']))
else:
error("Gitlab token {} is NOT VALID.".format(uc['api_token']))
......@@ -41,14 +41,19 @@ class UserConfig:
UserConfig.__instance = self
p = os.path.expanduser(config.local_conf)
if os.path.exists(p):
with open(p, 'r') as cf:
UserConfig.cfg = json.load(cf)
UserConfig.cfg_json = cf.read()
UserConfig.cfg = json.loads(UserConfig.cfg_json)
if 'debug' in [x.lower() for x in UserConfig.cfg.keys()]:
UserConfig.DEBUG = True
print("USERCONFIG: READ")
if 'courses' not in UserConfig.cfg:
UserConfig.cfg['courses'] = {}
else:
UserConfig.cfg = {}
UserConfig.cfg = {'courses': {}}
UserConfig.cfg_json = ""
UserConfig.__depth += 1
return UserConfig.__instance
......@@ -61,14 +66,19 @@ class UserConfig:
p = os.path.expanduser(config.local_conf)
if UserConfig.__instance:
userstr = json.dumps(
UserConfig.__instance.cfg,
indent=4,
sort_keys=True
)
if userstr == UserConfig.cfg_json:
if 'debug' in UserConfig.cfg:
print("USERCONFIG: CLEAN")
return
if 'debug' in UserConfig.cfg:
print("USERCONFIG: WRITE")
os.makedirs(os.path.dirname(p), exist_ok=True)
with open(p, 'w') as cf:
json.dump(
UserConfig.__instance.cfg,
cf,
indent=4,
sort_keys=True
)
cf.write(userstr)
UserConfig.__instance = None
......@@ -2,6 +2,7 @@
import os
import os.path
import json
import collections
from config.echo import *
from config.user import UserConfig
......@@ -20,39 +21,54 @@ def detect_course():
return coursename, coursepath
return None, None
def load_json(filepath):
"loads a json document from filepath"
debug('loading JSON config file from {}'.format(filepath))
with open(filepath, 'r') as fp:
return json.load(fp)
def load_rubric(coursename, labname):
"return a rubric doc or none"
debug("Looking for rubric for {}.{}".format(coursename, labname))
for pathname in all[coursename]['rubric_paths']:
tpath = os.path.join(pathname, labname + ".json")
if os.path.exists(tpath):
debug("Using rubric at {}".format(tpath))
with open(tpath, 'r') as fp:
return json.load(fp)
rub = load_json(tpath)
# ensure parts are sorted correctly
rub['parts'] = collections.OrderedDict(
sorted(rub['parts'].items(),key=lambda x: x[1]['index']))
return rub
return None
# define valid course strings
courses = ['CSCI206']
def load_courses(searchpath):
"searches paths for a courses.json file, if found loads each course"
debug("Looking for courses in {}".format(searchpath))
csci206_s20 = {
'instructors': ['amm042','xmeng','jvs008'],
'tas': ['zp002'],
c = {}
for pathname in searchpath:
tpath = os.path.join(pathname, "courses.json")
if os.path.exists(tpath):
courses = load_json(tpath)
for coursename, coursefile in courses.items():
c[coursename] = load_json(
os.path.join(pathname, coursefile))
return c
# rubric paths are searched in this order to allow mounting at various
# paths in the filesystem.
'rubric_paths':[
'/home/accounts/COURSES/cs206',
'/nfs/unixspace/linux/accounts/COURSES/cs206/2020-spring/rubrics',
'/unixspace/csci206/2020-spring/rubrics']
}
# places to search for coures.json, all courses are loaded
course_paths = ['/home/accounts/COURSES/cs206',
'/nfs/unixspace/linux/accounts/COURSES/cs206/',
'/unixspace/csci206/']
# dictionary of all course infos
all = {
'CSCI206-S20-60': csci206_s20,
'CSCI206-S20-61': csci206_s20,
'CSCI206-S20-62': csci206_s20
}
all = load_courses(course_paths)
# define valid course strings and course definition search paths
#courses = ['CSCI206']
# build list of course names
courses = []
for _c in all.values():
if _c['name'] not in courses:
courses.append(_c['name'])
__all__ = [all, courses]
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