Mercurial > ~astiob > upreckon > hgweb
annotate problem.py @ 90:1fb319ec33af
Skimming mode added (-k/--skim option)
In skimming mode, as soon as a single test case within a test group
is failed, the remaining test cases in the same group are skipped.
Bug fix and simply a bit of refactoring: TestCase.has_iofiles and
TestCase.has_ansfile are now defined (the meaning should be clear
from the names).
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Mon, 28 Feb 2011 15:32:22 +0000 |
parents | cd347cfca272 |
children | c62c9bfd614a |
rev | line source |
---|---|
77
69eadc60f4e2
Memory limit is now applied to the RSS when os.wait4 is available
Oleg Oshmyan <chortos@inbox.lv>
parents:
76
diff
changeset
|
1 # Copyright (c) 2010-2011 Chortos-2 <chortos@inbox.lv> |
16 | 2 |
21 | 3 from __future__ import division, with_statement |
4 | |
5 try: | |
6 from compat import * | |
7 import config, testcases | |
8 except ImportError: | |
9 import __main__ | |
10 __main__.import_error(sys.exc_info()[1]) | |
11 else: | |
85
741ae3391b61
Moved clock/time detection into platform-specific modules and testcases
Oleg Oshmyan <chortos@inbox.lv>
parents:
83
diff
changeset
|
12 from __main__ import options |
21 | 13 |
22 | 14 import os, re, sys |
21 | 15 |
16 | 16 try: |
75
007f7eb6fb2b
The test context stack is now a deque.
Oleg Oshmyan <chortos@inbox.lv>
parents:
74
diff
changeset
|
17 from collections import deque |
007f7eb6fb2b
The test context stack is now a deque.
Oleg Oshmyan <chortos@inbox.lv>
parents:
74
diff
changeset
|
18 except ImportError: |
007f7eb6fb2b
The test context stack is now a deque.
Oleg Oshmyan <chortos@inbox.lv>
parents:
74
diff
changeset
|
19 deque = list |
007f7eb6fb2b
The test context stack is now a deque.
Oleg Oshmyan <chortos@inbox.lv>
parents:
74
diff
changeset
|
20 |
007f7eb6fb2b
The test context stack is now a deque.
Oleg Oshmyan <chortos@inbox.lv>
parents:
74
diff
changeset
|
21 try: |
21 | 22 import signal |
23 except ImportError: | |
24 signalnames = () | |
25 else: | |
26 # Construct a cache of all signal names available on the current | |
27 # platform. Prefer names from the UNIX standards over other versions. | |
28 unixnames = frozenset(('HUP', 'INT', 'QUIT', 'ILL', 'ABRT', 'FPE', 'KILL', 'SEGV', 'PIPE', 'ALRM', 'TERM', 'USR1', 'USR2', 'CHLD', 'CONT', 'STOP', 'TSTP', 'TTIN', 'TTOU', 'BUS', 'POLL', 'PROF', 'SYS', 'TRAP', 'URG', 'VTALRM', 'XCPU', 'XFSZ')) | |
29 signalnames = {} | |
30 for name in dir(signal): | |
31 if re.match('SIG[A-Z]+$', name): | |
32 value = signal.__dict__[name] | |
22 | 33 if isinstance(value, int) and (value not in signalnames or name[3:] in unixnames): |
21 | 34 signalnames[value] = name |
35 del unixnames | |
16 | 36 |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
37 __all__ = 'Problem', 'TestContext', 'test_context_end', 'TestGroup' |
21 | 38 |
26 | 39 def strerror(e): |
40 s = getattr(e, 'strerror') | |
41 if not s: s = str(e) | |
42 return ' (%s%s)' % (s[0].lower(), s[1:]) if s else '' | |
21 | 43 |
44 class Cache(object): | |
45 def __init__(self, mydict): | |
46 self.__dict__ = mydict | |
16 | 47 |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
48 class TestContext(object): |
90
1fb319ec33af
Skimming mode added (-k/--skim option)
Oleg Oshmyan <chortos@inbox.lv>
parents:
88
diff
changeset
|
49 __slots__ = () |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
50 |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
51 test_context_end = object() |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
52 |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
53 class TestGroup(TestContext): |
76
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
54 __slots__ = 'points', 'case', 'log', 'correct', 'allcorrect', 'real', 'max', 'ntotal', 'nvalued', 'ncorrect', 'ncorrectvalued' |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
55 |
76
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
56 def __init__(self, points=None): |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
57 self.points = points |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
58 self.real = self.max = self.ntotal = self.nvalued = self.ncorrect = self.ncorrectvalued = 0 |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
59 self.allcorrect = True |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
60 self.log = [] |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
61 |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
62 def case_start(self, case): |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
63 self.case = case |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
64 self.correct = False |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
65 self.ntotal += 1 |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
66 if case.points: |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
67 self.nvalued += 1 |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
68 |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
69 def case_correct(self): |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
70 self.correct = True |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
71 self.ncorrect += 1 |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
72 if self.case.points: |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
73 self.ncorrectvalued += 1 |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
74 |
76
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
75 def case_end(self): |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
76 self.log.append((self.case, self.correct)) |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
77 del self.case |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
78 if not self.correct: |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
79 self.allcorrect = False |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
80 |
76
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
81 def score(self, real, max): |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
82 self.real += real |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
83 self.max += max |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
84 |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
85 def end(self): |
76
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
86 if not self.allcorrect: |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
87 self.real = 0 |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
88 if self.points is not None and self.points != self.max: |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
89 max, weighted = self.points, self.real * self.points / self.max if self.max else 0 |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
90 before_weighting = ' (%g/%g before weighting)' % (self.real, self.max) |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
91 else: |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
92 max, weighted = self.max, self.real |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
93 before_weighting = '' |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
94 say('Group total: %d/%d tests, %g/%g points%s' % (self.ncorrect, self.ntotal, weighted, max, before_weighting)) |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
95 # No real need to flush stdout, as it will anyway be flushed in a moment, |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
96 # when either the problem total or the next test case's ID is printed |
76
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
97 return weighted, max, self.log |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
98 |
16 | 99 class Problem(object): |
100 __slots__ = 'name', 'config', 'cache', 'testcases' | |
101 | |
102 def __init__(prob, name): | |
103 if not isinstance(name, basestring): | |
104 # This shouldn't happen, of course | |
21 | 105 raise TypeError('Problem() argument 1 must be string, not ' + type(name).__name__) |
16 | 106 prob.name = name |
21 | 107 prob.config = config.load_problem(name) |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
108 prob.cache = Cache({'padoutput': 0}) |
21 | 109 prob.testcases = testcases.load_problem(prob) |
110 | |
111 # TODO | |
112 def build(prob): | |
113 raise NotImplementedError | |
16 | 114 |
115 def test(prob): | |
23 | 116 case = None |
22 | 117 try: |
75
007f7eb6fb2b
The test context stack is now a deque.
Oleg Oshmyan <chortos@inbox.lv>
parents:
74
diff
changeset
|
118 contexts = deque((TestGroup(),)) |
22 | 119 for case in prob.testcases: |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
120 if case is test_context_end: |
76
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
121 real, max, log = contexts.pop().end() |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
122 for case, correct in log: |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
123 contexts[-1].case_start(case) |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
124 if correct: |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
125 contexts[-1].case_correct() |
76
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
126 contexts[-1].case_end() |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
127 contexts[-1].score(real, max) |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
128 continue |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
129 elif isinstance(case, TestContext): |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
130 contexts.append(case) |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
131 continue |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
132 contexts[-1].case_start(case) |
22 | 133 granted = 0 |
134 id = str(case.id) | |
135 if case.isdummy: | |
136 id = 'sample ' + id | |
137 say('%*s: ' % (prob.cache.padoutput, id), end='') | |
138 sys.stdout.flush() | |
139 try: | |
140 granted = case(lambda: (say('%7.3f%s s, ' % (case.time_stopped - case.time_started, case.time_limit_string), end=''), sys.stdout.flush())) | |
90
1fb319ec33af
Skimming mode added (-k/--skim option)
Oleg Oshmyan <chortos@inbox.lv>
parents:
88
diff
changeset
|
141 except testcases.TestCaseSkipped: |
1fb319ec33af
Skimming mode added (-k/--skim option)
Oleg Oshmyan <chortos@inbox.lv>
parents:
88
diff
changeset
|
142 verdict = 'skipped due to skimming mode' |
22 | 143 except testcases.CanceledByUser: |
144 verdict = 'canceled by the user' | |
82
06356af50bf9
Finished testcases reorganization and CPU time limit implementation
Oleg Oshmyan <chortos@inbox.lv>
parents:
77
diff
changeset
|
145 except testcases.WallTimeLimitExceeded: |
06356af50bf9
Finished testcases reorganization and CPU time limit implementation
Oleg Oshmyan <chortos@inbox.lv>
parents:
77
diff
changeset
|
146 verdict = 'wall-clock time limit exceeded' |
06356af50bf9
Finished testcases reorganization and CPU time limit implementation
Oleg Oshmyan <chortos@inbox.lv>
parents:
77
diff
changeset
|
147 except testcases.CPUTimeLimitExceeded: |
06356af50bf9
Finished testcases reorganization and CPU time limit implementation
Oleg Oshmyan <chortos@inbox.lv>
parents:
77
diff
changeset
|
148 verdict = 'CPU time limit exceeded' |
77
69eadc60f4e2
Memory limit is now applied to the RSS when os.wait4 is available
Oleg Oshmyan <chortos@inbox.lv>
parents:
76
diff
changeset
|
149 except testcases.MemoryLimitExceeded: |
69eadc60f4e2
Memory limit is now applied to the RSS when os.wait4 is available
Oleg Oshmyan <chortos@inbox.lv>
parents:
76
diff
changeset
|
150 verdict = 'memory limit exceeded' |
22 | 151 except testcases.WrongAnswer: |
152 e = sys.exc_info()[1] | |
153 if e.comment: | |
154 verdict = 'wrong answer (%s)' % e.comment | |
155 else: | |
156 verdict = 'wrong answer' | |
157 except testcases.NonZeroExitCode: | |
158 e = sys.exc_info()[1] | |
159 if e.exitcode < 0: | |
160 if sys.platform == 'win32': | |
161 verdict = 'terminated with error 0x%X' % (e.exitcode + 0x100000000) | |
162 elif -e.exitcode in signalnames: | |
163 verdict = 'terminated by signal %d (%s)' % (-e.exitcode, signalnames[-e.exitcode]) | |
164 else: | |
165 verdict = 'terminated by signal %d' % -e.exitcode | |
21 | 166 else: |
22 | 167 verdict = 'non-zero return code %d' % e.exitcode |
168 except testcases.CannotStartTestee: | |
26 | 169 verdict = 'cannot launch the program to test%s' % strerror(sys.exc_info()[1].upstream) |
22 | 170 except testcases.CannotStartValidator: |
26 | 171 verdict = 'cannot launch the validator%s' % strerror(sys.exc_info()[1].upstream) |
22 | 172 except testcases.CannotReadOutputFile: |
26 | 173 verdict = 'cannot read the output file%s' % strerror(sys.exc_info()[1].upstream) |
22 | 174 except testcases.CannotReadInputFile: |
26 | 175 verdict = 'cannot read the input file%s' % strerror(sys.exc_info()[1].upstream) |
22 | 176 except testcases.CannotReadAnswerFile: |
26 | 177 verdict = 'cannot read the reference output file%s' % strerror(sys.exc_info()[1].upstream) |
22 | 178 except testcases.TestCaseNotPassed: |
26 | 179 verdict = 'unspecified reason [this may be a bug in test.py]%s' % strerror(sys.exc_info()[1]) |
22 | 180 #except Exception: |
26 | 181 # verdict = 'unknown error [this may be a bug in test.py]%s' % strerror(sys.exc_info()[1]) |
21 | 182 else: |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
183 try: |
22 | 184 granted, comment = granted |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
185 except TypeError: |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
186 comment = '' |
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
187 else: |
22 | 188 if comment: |
189 comment = ' (%s)' % comment | |
24
c23d81f4a1a3
Score returned by TestCase.__call__() is now normalized to 0..1
Oleg Oshmyan <chortos@inbox.lv>
parents:
23
diff
changeset
|
190 if granted >= 1: |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
191 contexts[-1].case_correct() |
90
1fb319ec33af
Skimming mode added (-k/--skim option)
Oleg Oshmyan <chortos@inbox.lv>
parents:
88
diff
changeset
|
192 prob.testcases.send(True) |
22 | 193 verdict = 'OK' + comment |
194 elif not granted: | |
195 verdict = 'wrong answer' + comment | |
196 else: | |
197 verdict = 'partly correct' + comment | |
26 | 198 granted *= case.points |
22 | 199 say('%g/%g, %s' % (granted, case.points, verdict)) |
76
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
200 contexts[-1].case_end() |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
201 contexts[-1].score(granted, case.points) |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
202 weighted = contexts[0].real * prob.config.taskweight / contexts[0].max if contexts[0].max else 0 |
76
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
203 before_weighting = valued = '' |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
204 if prob.config.taskweight != contexts[0].max: |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
205 before_weighting = ' (%g/%g before weighting)' % (contexts[0].real, contexts[0].max) |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
206 if contexts[0].nvalued != contexts[0].ntotal: |
76
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
207 valued = ' (%d/%d valued)' % (contexts[0].ncorrectvalued, contexts[0].nvalued) |
0e5ae28e0b2b
Points are now weighted on a test context basis
Oleg Oshmyan <chortos@inbox.lv>
parents:
75
diff
changeset
|
208 say('Problem total: %d/%d tests%s, %g/%g points%s' % (contexts[0].ncorrect, contexts[0].ntotal, valued, weighted, prob.config.taskweight, before_weighting)) |
39
2b459f9743b4
Test groups are now supported
Oleg Oshmyan <chortos@inbox.lv>
parents:
26
diff
changeset
|
209 sys.stdout.flush() |
22 | 210 return weighted, prob.config.taskweight |
211 finally: | |
90
1fb319ec33af
Skimming mode added (-k/--skim option)
Oleg Oshmyan <chortos@inbox.lv>
parents:
88
diff
changeset
|
212 if options.erase and case and case.has_iofiles: |
22 | 213 for var in 'in', 'out': |
214 name = getattr(prob.config, var + 'name') | |
215 if name: | |
216 try: | |
217 os.remove(name) | |
218 except Exception: | |
219 pass | |
90
1fb319ec33af
Skimming mode added (-k/--skim option)
Oleg Oshmyan <chortos@inbox.lv>
parents:
88
diff
changeset
|
220 if case.has_ansfile: |
22 | 221 if prob.config.ansname: |
222 try: | |
223 os.remove(prob.config.ansname) | |
224 except Exception: | |
225 pass |