From 7194c7eebc846861ab402c6c35daa01cb614c26c Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 12 Aug 2009 01:55:26 +0200 Subject: [PATCH] Err -> Error in all exception names (to be consistent with naming of standard Python exceptions) --- t/moe/__init__.py | 6 +++--- t/moe/batch.py | 22 +++++++++++----------- t/moe/box.py | 6 +++--- t/moe/config.py | 6 +++--- t/moe/eval.py | 8 ++++---- t/moe/pipeline.py | 2 +- t/moe/testcase.py | 10 +++++----- t/test.py | 6 +++--- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/t/moe/__init__.py b/t/moe/__init__.py index 2ce5499..63ca9b6 100644 --- a/t/moe/__init__.py +++ b/t/moe/__init__.py @@ -1,9 +1,9 @@ # 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 @@ -15,5 +15,5 @@ class SolutionErr(Exception): else: return "%s: %s" % (self.stat_code, self.message) -class TestErr(SolutionErr): +class TestError(SolutionError): pass diff --git a/t/moe/batch.py b/t/moe/batch.py index 4e3dcf9..22707bb 100644 --- a/t/moe/batch.py +++ b/t/moe/batch.py @@ -17,7 +17,7 @@ def try_ext(e, ext): 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... ") @@ -33,7 +33,7 @@ def locate(e, filename=None): 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: @@ -42,9 +42,9 @@ def locate(e, filename=None): 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 @@ -94,7 +94,7 @@ def compile_done(e): 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): @@ -107,7 +107,7 @@ 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) @@ -127,9 +127,9 @@ def test_in(e): 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"] @@ -144,7 +144,7 @@ def test_in(e): 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) @@ -157,7 +157,7 @@ def test_run(e): 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"] @@ -170,7 +170,7 @@ def test_collect(e): 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): diff --git a/t/moe/box.py b/t/moe/box.py index 321eedd..dfb9282 100644 --- a/t/moe/box.py +++ b/t/moe/box.py @@ -21,7 +21,7 @@ def init(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"]) @@ -44,7 +44,7 @@ def run(e, opts, cmd): 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 diff --git a/t/moe/config.py b/t/moe/config.py index 7f015da..95cc316 100644 --- a/t/moe/config.py +++ b/t/moe/config.py @@ -7,10 +7,10 @@ import moe 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: @@ -140,7 +140,7 @@ class MoeConfigStack: 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] diff --git a/t/moe/eval.py b/t/moe/eval.py index f3e921a..6c6a608 100644 --- a/t/moe/eval.py +++ b/t/moe/eval.py @@ -45,7 +45,7 @@ class Eval: 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() @@ -60,7 +60,7 @@ class Eval: 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) @@ -72,9 +72,9 @@ class Eval: 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") diff --git a/t/moe/pipeline.py b/t/moe/pipeline.py index 7726110..f14a0f5 100644 --- a/t/moe/pipeline.py +++ b/t/moe/pipeline.py @@ -6,7 +6,7 @@ import imp import moe import moe.log -class MoePipeError(moe.MoeErr): +class MoePipeError(moe.MoeError): """Failure of the MoePipeline.""" class MoeAbortPipeline(Exception): diff --git a/t/moe/testcase.py b/t/moe/testcase.py index e49bd8c..158f374 100644 --- a/t/moe/testcase.py +++ b/t/moe/testcase.py @@ -80,8 +80,8 @@ def judge(e): 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 @@ -100,8 +100,8 @@ def run_test(e, test): 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 @@ -139,7 +139,7 @@ def run_tests(e): 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 diff --git a/t/test.py b/t/test.py index 07a220f..73e3c49 100755 --- a/t/test.py +++ b/t/test.py @@ -19,7 +19,7 @@ try: 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) @@ -30,10 +30,10 @@ try: 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) -- 2.39.2