# No initialization needed
-class MoeErr(Exception):
+class MoeError(Exception):
pass
-class SolutionErr(Exception):
+class SolutionError(Exception):
def __init__(self, message, stat_code=None):
self.stat_code = stat_code
else:
return "%s: %s" % (self.stat_code, self.message)
-class TestErr(SolutionErr):
+class TestError(SolutionError):
pass
for e in e.cfgs["EXTENSIONS"].split():
if e == ext:
return
- raise moe.MoeErr, "Unknown extension: " + ext
+ raise moe.MoeError, "Unknown extension: " + ext
def locate(e, filename=None):
e.log.progress("Locating source... ")
base, ext = os.path.splitext(file)
if ext != "":
if not os.path.exists(os.path.join(dir, file)):
- raise moe.SolutionErr, "No solution of %s called %s found" % (task,file)
+ raise moe.SolutionError, "No solution of %s called %s found" % (task,file)
ext = ext[1:]
try_ext(e, ext)
else:
if os.path.exists(os.path.join(dir, base + "." + ext)):
found.append(ext)
if len(found) == 0:
- raise moe.SolutionErr, "No solution of %s found" % task
+ raise moe.SolutionError, "No solution of %s found" % task
if len(found) > 1:
- raise moe.SolutionErr, "Multiple solutions of %s found" % task
+ raise moe.SolutionError, "Multiple solutions of %s found" % task
ext = found[0]
file = base + "." + ext
try:
shutil.copyfile(os.path.join(e.cfgs["BOXDIR"], e.cfgs["EXE"]), os.path.join(e.cfgs["TDIR"], e.cfgs["EXE"]))
except IOError:
- raise moe.MoeErr, "Compiler succeeded, but produced no output"
+ raise moe.MoeError, "Compiler succeeded, but produced no output"
e.log.progress("OK\n")
def test_in(e):
sandbox_opts = "-M" + os.path.join(tdir, e.cfgs["TESTCASE_STATUS"])
if not os.path.exists(os.path.join(tdir, e.cfgs["EXE"])):
- raise TestErr("Compilation failed", "CE")
+ raise TestError("Compilation failed", "CE")
shutil.copyfile(os.path.join(tdir, e.cfgs["EXE"]), os.path.join(boxdir, e.cfgs["EXE"]))
os.chmod(os.path.join(boxdir, e.cfgs["EXE"]), 0555)
sandbox_opts += " -i/dev/null"
elif in_type == "dir":
## FIXME
- raise MoeErr, "Directory input not yet implemented"
+ raise MoeError, "Directory input not yet implemented"
else:
- raise MoeErr, "Unknown input type %s" % in_type
+ raise MoeError, "Unknown input type %s" % in_type
if out_type == "file":
out_name = e.cfgs["OUT_NAME"]
if not is_interactive:
sandbox_opts += " -o/dev/null"
else:
- raise MoeErr, "Unknown output type %s" % out_type
+ raise MoeError, "Unknown output type %s" % out_type
e.test_builtins.set("BOX_IO_OPTS", sandbox_opts)
moe.testcase.collect_status(e)
moe.box.show(e, "test output")
if rc > 0:
- raise moe.TestErr("Wrong answer", "WA")
+ raise moe.TestError("Wrong answer", "WA")
def test_collect(e):
tdir = e.cfgs["TDIR"]
elif out_type == "stdio":
out_path = ".stdout"
if not os.path.exists(os.path.join(boxdir, out_path)):
- raise moe.TestErr("No output file", "NO")
+ raise moe.TestError("No output file", "NO")
shutil.copyfile(os.path.join(boxdir, out_path), os.path.join(tdir, e.cfgs["TESTCASE_OUT"]))
def tests(e):
e.log.verbose("Sandbox directory: %s\n" % dir)
e.log.verbose("Sandbox command: %s\n" % cmd)
if dir == "" or not os.path.isdir(dir) or exe == "" or not os.path.isfile(exe):
- raise moe.MoeErr, "Sandbox set up incorrectly"
+ raise moe.MoeError, "Sandbox set up incorrectly"
def clean(e):
moe.util.remove_tree_contents(e.cfgs["BOXDIR"])
if os.WIFEXITED(st):
rc = os.WEXITSTATUS(st)
if rc > 1:
- raise moe.MoeErr, "Sandbox failed with rc=%d" % rc
+ raise moe.MoeError, "Sandbox failed with rc=%d" % rc
return rc
else:
- raise moe.MoeErr, "Sandbox failed with exit status 0x%04x" % rc
+ raise moe.MoeError, "Sandbox failed with exit status 0x%04x" % rc
key_pattern = re.compile("^[A-Za-z0-9_-]+$")
ref_pattern = re.compile("^[A-Za-z0-9_-]+")
-class MoeConfigInvalid(moe.MoeErr):
+class MoeConfigInvalid(moe.MoeError):
pass
-class MoeConfigEvalErr(moe.MoeErr):
+class MoeConfigEvalError(moe.MoeError):
pass
class MoeConfig:
if self.cache.has_key(k):
return self.cache[k]
if self.in_progress.has_key(k):
- raise MoeConfigEvalErr, "Definition of $%s is recursive" % k;
+ raise MoeConfigEvalError, "Definition of $%s is recursive" % k;
self.in_progress[k] = 1;
v = self.do_get(k, len(self.stk)-1)
del self.in_progress[k]
try:
moe.util.mkdir_tree(test)
except OSError, e:
- raise moe.MoeErr, "Cannot create %s: %s" % (test, e.strerror)
+ raise moe.MoeError, "Cannot create %s: %s" % (test, e.strerror)
def init_logs(self):
self.log = moe.log.MoeLog()
task = self.cfgs['TASK']
task_dir = self.cfgs['PDIR']
if not os.path.isdir(task_dir):
- raise moe.MoeErr, "No such task %s" % task
+ raise moe.MoeError, "No such task %s" % task
task_cfg = moe.config.MoeConfig(name = os.path.join(task_dir, "config"), type='task')
self.cfgs.push(task_cfg)
if type == "batch" or type == "interactive":
moe.batch.prepare_pipe(self)
elif type == "opendata":
- raise moe.MoeErr, "Opendata tasks not implemented yet"
+ raise moe.MoeError, "Opendata tasks not implemented yet"
else:
- raise moe.MoeErr, "Unknown task type " + type
+ raise moe.MoeError, "Unknown task type " + type
def run(self):
self.log_config(2, "for the task pipeline")
import moe
import moe.log
-class MoePipeError(moe.MoeErr):
+class MoePipeError(moe.MoeError):
"""Failure of the MoePipeline."""
class MoeAbortPipeline(Exception):
if os.WEXITSTATUS(rc) == 0:
return
elif os.WEXITSTATUS(rc) == 1:
- raise moe.TestErr("Wrong answer", "WA")
- raise moe.MoeErr("Judge failure")
+ raise moe.TestError("Wrong answer", "WA")
+ raise moe.MoeError("Judge failure")
def points(e):
## FIXME: check $TEST.pts
def wrap_run_test(e, test):
try:
run_test(e, test)
- except moe.MoeErr, err:
- raise moe.TestErr(err, "XX")
+ except moe.MoeError, err:
+ raise moe.TestError(err, "XX")
def conclude_test(e):
stat = e.test_stat
try:
wrap_run_test(e, test)
- except moe.TestErr, err:
+ except moe.TestError, err:
if not e.test_stat["status"]:
e.test_stat["status"] = err.stat_code
e.test_stat["message"] = err.message
e.builtins.set("CONTESTANT", "mj")
e.log.progress("### Evaluating task %s of contestant %s ###\n\n" % (e.cfgs['TASK'], e.cfgs['CONTESTANT']))
e.init(overrides)
-except moe.MoeErr, err:
+except moe.MoeError, err:
e.log.shout("FATAL: %s\n" % err)
sys.exit(1)
file = None
moe.batch.locate(e, file)
e.run()
-except moe.MoeErr, err:
+except moe.MoeError, err:
e.log.shout("FATAL: %s\n" % err)
sys.exit(1)
-except moe.SolutionErr, err:
+except moe.SolutionError, err:
e.stat["error"] = err
e.log.shout("%s\n" % err)