From 33635b1f32cce22b8f4f9118d951e10eae590001 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Sun, 12 Mar 2017 13:02:51 -0700 Subject: [PATCH] releasetools: Fix the diff_worker progress report. Test: Observe the progress update during an incremental generation. Change-Id: Ib0629a0fd9f925076fd20a040345c4f169133c30 --- tools/releasetools/blockimgdiff.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py index ed087c1d2..d8fcc411b 100644 --- a/tools/releasetools/blockimgdiff.py +++ b/tools/releasetools/blockimgdiff.py @@ -718,6 +718,9 @@ class BlockImageDiff(object): diff_total = len(diff_queue) patches = [None] * diff_total + if sys.stdout.isatty(): + global diff_done + diff_done = 0 # Using multiprocessing doesn't give additional benefits, due to the # pattern of the code. The diffing work is done by subprocess.call, which @@ -758,7 +761,9 @@ class BlockImageDiff(object): with lock: patches[patch_index] = (xf_index, patch) if sys.stdout.isatty(): - progress = len(patches) * 100 / diff_total + global diff_done + diff_done += 1 + progress = diff_done * 100 / diff_total # '\033[K' is to clear to EOL. print(' [%d%%] %s\033[K' % (progress, xf.tgt_name), end='\r') sys.stdout.flush()