aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/bootstrap_commands.py
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2018-10-11 16:09:12 +0200
committerSimon Sapin <simon.sapin@exyr.org>2018-10-11 19:11:32 +0200
commitf0d8e8af49639678d1bd4d99855ae70737615a7a (patch)
treee6003a69daed64b60a08f0ab54fbe6d68557af48 /python/servo/bootstrap_commands.py
parent6c82c471c526f7d08613ba70659e51d248b07f82 (diff)
downloadservo-f0d8e8af49639678d1bd4d99855ae70737615a7a.tar.gz
servo-f0d8e8af49639678d1bd4d99855ae70737615a7a.zip
Reduce log spam when running sdkmanager
Diffstat (limited to 'python/servo/bootstrap_commands.py')
-rw-r--r--python/servo/bootstrap_commands.py35
1 files changed, 29 insertions, 6 deletions
diff --git a/python/servo/bootstrap_commands.py b/python/servo/bootstrap_commands.py
index 4ef19b2b45f..6361fa8189a 100644
--- a/python/servo/bootstrap_commands.py
+++ b/python/servo/bootstrap_commands.py
@@ -163,8 +163,35 @@ class MachCommands(CommandBase):
sdkmanager = [path.join(toolchains, "sdk", "tools", "bin", "sdkmanager")] + components
if accept_all_licences:
yes = subprocess.Popen(["yes"], stdout=subprocess.PIPE)
- subprocess.check_call(sdkmanager, stdin=yes.stdout)
+ process = subprocess.Popen(
+ sdkmanager, stdin=yes.stdout, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ )
+ # Reduce progress bar spam by removing duplicate lines.
+ # Printing the same line again with \r is a no-op in a real terminal,
+ # but each line is shown individually in Taskcluster's log viewer.
+ previous_line = None
+ line = b""
+ while 1:
+ # Read one byte at a time because in Python:
+ # * readline() blocks until "\n", which doesn't come before the prompt
+ # * read() blocks until EOF, which doesn't come before the prompt
+ # * read(n) keeps reading until it gets n bytes or EOF,
+ # but we don't know reliably how many bytes to read until the prompt
+ byte = process.stdout.read(1)
+ if len(byte) == 0:
+ print(line)
+ break
+ line += byte
+ if byte == b'\n' or byte == b'\r':
+ if line != previous_line:
+ print(line.decode("utf-8", "replace"), end="")
+ sys.stdout.flush()
+ previous_line = line
+ line = b""
+ exit_code = process.wait()
yes.terminate()
+ if exit_code:
+ return exit_code
else:
subprocess.check_call(sdkmanager)
@@ -180,11 +207,7 @@ class MachCommands(CommandBase):
])
output = b""
while 1:
- # Read one byte at a time because in Python:
- # * readline() blocks until "\n", which doesn't come before the prompt
- # * read() blocks until EOF, which doesn't come before the prompt
- # * read(n) keeps reading until it gets n bytes or EOF,
- # but we don't know reliably how many bytes to read until the prompt
+ # Read one byte at a time, see comment above.
byte = process.stdout.read(1)
if len(byte) == 0:
break