Merge ~sylvain-pineau/checkbox-ng:no_tty_no_tqdm into checkbox-ng:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 9b62cff00512e050bf5bd2d4bc7f82facb1bec21
Merged at revision: c8e9f431b039dca65d79e922ef3c1a2d9039cd84
Proposed branch: ~sylvain-pineau/checkbox-ng:no_tty_no_tqdm
Merge into: checkbox-ng:master
Diff against target: 41 lines (+8/-18)
1 file modified
checkbox_ng/launcher/master.py (+8/-18)
Reviewer Review Type Date Requested Status
Jonathan Cave (community) Approve
Maciej Kisielewski (community) Approve
Review via email: mp+380955@code.launchpad.net

Description of the change

tqdm progress bar are messing up jenkins console logs.
tqdm supports a disable flag, let's use it when there's no tty.

To post a comment you must log in.
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

LGTM, +1

review: Approve
Revision history for this message
Jonathan Cave (jocave) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/checkbox_ng/launcher/master.py b/checkbox_ng/launcher/master.py
2index 8c29e91..9009266 100644
3--- a/checkbox_ng/launcher/master.py
4+++ b/checkbox_ng/launcher/master.py
5@@ -453,28 +453,18 @@ class RemoteMaster(ReportsStage, MainLoopStage):
6 self.abandon()
7 self.new_session()
8
9- def _download_file(conn, remotepath, localpath, chunk_size=16384):
10- try:
11- rf = conn.root.open(remotepath, "rb")
12- with tqdm(total=conn.root.getsize(remotepath), unit='B', unit_scale=True, unit_divisor=1024) as pbar:
13- with open(localpath, "wb") as lf:
14- while True:
15- buf = rf.read(chunk_size)
16- pbar.set_postfix(file=remotepath, refresh=False)
17- pbar.update(chunk_size)
18- if not buf:
19- break
20- #time.sleep(0.01)
21- lf.write(buf)
22- finally:
23- rf.close()
24-
25 def local_export(self, exporter_id, transport, options=()):
26 _logger.info("master: Exporting locally'")
27 rf = self.sa.cache_report(exporter_id, options)
28 exported_stream = SpooledTemporaryFile(max_size=102400, mode='w+b')
29- chunk_size=16384
30- with tqdm(total=rf.tell(), unit='B', unit_scale=True, unit_divisor=1024) as pbar:
31+ chunk_size = 16384
32+ with tqdm(
33+ total=rf.tell(),
34+ unit='B',
35+ unit_scale=True,
36+ unit_divisor=1024,
37+ disable=not self.is_interactive
38+ ) as pbar:
39 rf.seek(0)
40 while True:
41 buf = rf.read(chunk_size)

Subscribers

People subscribed via source and target branches