From 74bd4e04e1801a7bfcd5d2c5b09fb6b5989097b3 Mon Sep 17 00:00:00 2001 From: Taeyeon Mori Date: Sun, 12 Nov 2017 00:25:01 +0900 Subject: [PATCH] xconv: Fix task reporting --- lib/python/xconv/app.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/python/xconv/app.py b/lib/python/xconv/app.py index 90ba5d0..5eba161 100644 --- a/lib/python/xconv/app.py +++ b/lib/python/xconv/app.py @@ -33,6 +33,7 @@ from os.path import isdir, join as build_path, basename, dirname, splitext, exis from os import environ, makedirs, mkdir from shutil import copyfile from pathlib import Path +from functools import partial # == Extend AAV == @@ -62,8 +63,21 @@ class AdvancedTask(advancedav.Task): class Manager(advancedav.MultiAV): def _spawn_next(self, **b): - print("\033[32m Processing '%s'\033[0m" % task_name(self.queue[0][1])) - return super()._spawn_next(**b) + task = self.queue[0][1] + + print("\033[32m Processing '%s'\033[0m" % task_name(task)) + + proc, f = super()._spawn_next(**b) + + f.then(partial(task_done, task)).catch(partial(task_fail, task)) + + return proc, f + +def task_done(task, res): + print("\033[32m Finished '%s'\033[0m" % task_name(task)) + +def task_fail(task, exc): + print("\033[31m Failed '%s': %s\033[0m" % (task_name(task), exc)) # == App == @@ -210,11 +224,7 @@ def main(argv): tasks = sum([task.split(args.concurrent) for task in tasks], []) # Commit - for task in tasks: - name = task_name(task) - task.commit2().then(lambda x: print("\033[32m Finished '%s'\033[0m" % name))\ - .catch(lambda e: print("\033[31m Failed '%s': %s\033[0m" % (name, e))) - + [t.commit2() for t in tasks] aav.process_queue() aav.wait()