def process_commands(argv): with open(argv[2]) as f: uplcourse = eval(f.read()) conf_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), '../../host/tornado/conf')) conf_file = os.path.join(conf_dir, 'tornado.conf') user_conf_file = os.path.join('/jboxengine/conf', 'jbox.user') JBoxCfg.read(conf_file, user_conf_file) LoggerMixin.configure() db.configure() Compute.configure() cmd = argv[1] if cmd == "upload": HomeworkHandler.upload_course(None, uplcourse) elif cmd == "report": as_csv = (argv[3] == "csv") if len(argv) > 3 else False get_report(uplcourse, as_csv) elif cmd == "answers": get_answers(uplcourse) else: print("Unknown option %s" % (cmd, )) print("DONE!")
from jbox_util import JBoxCfg, LoggerMixin, unique_sessname from juliabox import db from juliabox.db import JBoxDynConfig, JBoxSessionProps, JBoxUserV2 from juliabox.cloud import JBPluginCloud from juliabox.cloud import Compute conf_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../conf')) conf_file = os.path.join(conf_dir, 'tornado.conf') user_conf_file = os.path.join(conf_dir, 'jbox.user') JBoxCfg.read(conf_file, user_conf_file) JBoxCfg.dckr = docker.Client() LoggerMixin.configure() db.configure() Compute.configure() TESTCLSTR = 'testcluster' class TestDBTables(LoggerMixin): @staticmethod def test(): sprops = JBoxSessionProps(TESTCLSTR, unique_sessname('*****@*****.**')) TestDBTables.log_debug("JBoxSessionProps. user_id: %s, snapshot_id: %s, message: %s", sprops.get_user_id(), sprops.get_snapshot_id(), sprops.get_message()) JBoxDynConfig.set_cluster_leader(TESTCLSTR, 'testinstance') assert JBoxDynConfig.get_cluster_leader(TESTCLSTR) == 'testinstance'