]> mj.ucw.cz Git - eval.git/commitdiff
Err -> Error in all exception names (to be consistent with naming of standard Python...
authorMartin Mares <mj@ucw.cz>
Tue, 11 Aug 2009 23:55:26 +0000 (01:55 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 11 Aug 2009 23:55:26 +0000 (01:55 +0200)
t/moe/__init__.py
t/moe/batch.py
t/moe/box.py
t/moe/config.py
t/moe/eval.py
t/moe/pipeline.py
t/moe/testcase.py
t/test.py

index 2ce549975d842130c7c3fe8876b24f690709f790..63ca9b65108c95a7fc957e8fff77706427ec664e 100644 (file)
@@ -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
index 4e3dcf92684327ad7b04b12de74395ac3865598e..22707bbf93616dae0d0a73f89671b0c9772eb4df 100644 (file)
@@ -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):
index 321eedd15fe585e0e49a0ad883f374970baf0ba1..dfb9282aa626123712f7aca76a69c3c0b016b327 100644 (file)
@@ -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
index 7f015da92aec253a3552fc58d1ee1934c65b3ee0..95cc316b4972cfb5020a24bfba4bba94752f10f9 100644 (file)
@@ -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]
index f3e921a265ba3247fe528eb4078f5e820747bb96..6c6a608ca2ea11474f15d0111faadc0a73fddae2 100644 (file)
@@ -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")
index 7726110ccf32b2bd313324121b20ac75ee36eb82..f14a0f5f7956be474151c6148474b94bc86f525f 100644 (file)
@@ -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):
index e49bd8c3d1428793fc373c66ebf057b0ca5217a9..158f3742c36098896d78d8481751742166db6659 100644 (file)
@@ -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
index 07a220fe96a51bb7e11e96abc46341ab2ae43d55..73e3c49cfd68fd5b2b0dc6ea87caf86f30836627 100755 (executable)
--- 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)