Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Commit d68400d

Browse files
committed
Missing running tasks in terry ui
1 parent 23aa48d commit d68400d

4 files changed

Lines changed: 20 additions & 14 deletions

File tree

python/sanity_checks/ioi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _check_graders(folder: str, languages: Set[Language],
3434

3535
def _get_statement_path():
3636
for path in ["statement/statement.pdf", "testo/testo.pdf"]:
37-
if os.path.exists(path):
37+
if os.path.lexists(path):
3838
return path
3939
return None
4040

python/uis/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ def _print_final_messages(self):
233233
class CursesUI(ABC):
234234
FPS = 30
235235

236-
def __init__(self):
236+
def __init__(self, interface: UIInterface):
237+
self.interface = interface
237238
self.thread = threading.Thread(
238239
target=curses.wrapper, args=(self._wrapper, ))
239240
self.stopped = False
@@ -291,6 +292,16 @@ def _wrapper(self, stdscr):
291292
def _loop(self, printer: CursesPrinter, loading: str):
292293
pass
293294

295+
def _print_running_tasks(self, printer: CursesPrinter):
296+
printer.blue("Running tasks:\n", bold=True)
297+
running = sorted(
298+
(t, n) for n, t in self.interface.running.copy().items())
299+
now = time.monotonic()
300+
for start, task in running:
301+
duration = now - start
302+
printer.text(" - {0: <50} {1: .1f}s\n".format(
303+
task.strip(), duration))
304+
294305

295306
def result_to_str(result: Result) -> str:
296307
status = result.status

python/uis/ioi_curses_ui.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ def print_solutions_result(printer: Printer, task: Task,
167167

168168
class IOICursesUI(CursesUI):
169169
def __init__(self, interface: IOIUIInterface):
170-
super().__init__()
171-
self.interface = interface
170+
super().__init__(interface)
172171

173172
def _loop(self, printer: CursesPrinter, loading: str):
174173
max_sol_len = 1 + get_max_sol_len(self.interface)
@@ -204,11 +203,4 @@ def _loop(self, printer: CursesPrinter, loading: str):
204203

205204
printer.text("\n")
206205

207-
printer.blue("Running tasks:\n", bold=True)
208-
running = sorted(
209-
(t, n) for n, t in self.interface.running.copy().items())
210-
now = time.monotonic()
211-
for start, task in running:
212-
duration = now - start
213-
printer.text(" - {0: <50} {1: .1f}s\n".format(
214-
task.strip(), duration))
206+
self._print_running_tasks(printer)

python/uis/terry_curses_ui.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def print_terry_solution_info(printer: CursesPrinter, solution: str,
5353

5454
class TerryCursesUI(CursesUI):
5555
def __init__(self, interface: TerryUIInterface):
56-
super().__init__()
57-
self.interface = interface
56+
super().__init__(interface)
5857

5958
def _loop(self, printer: CursesPrinter, loading: str):
6059
printer.bold("Running... %s\n" % self.interface.task.name)
@@ -75,3 +74,7 @@ def _loop(self, printer: CursesPrinter, loading: str):
7574
for solution, info in self.interface.solutions_info.items():
7675
print_terry_solution_info(printer, solution, info, max_sol_len,
7776
loading, self.interface.task.max_score)
77+
78+
printer.text("\n")
79+
80+
self._print_running_tasks(printer)

0 commit comments

Comments
 (0)