Commit a7c16c2d by Jamie Madill Committed by Commit Bot

Trace Tests: Print trace download progress.

As the hook runs, we'll now be printing each trace's progress. This uses some tricks with Python's subprocess. Bug: angleproject:5210 Change-Id: I4e776a89c2b3e06ba67f9a82969aa394b24208d5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2491104 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent 5dcd29a6
...@@ -540,7 +540,7 @@ hooks = [ ...@@ -540,7 +540,7 @@ hooks = [
'name': 'restricted_traces', 'name': 'restricted_traces',
'pattern': '\\.sha1', 'pattern': '\\.sha1',
'condition': 'checkout_angle_internal', 'condition': 'checkout_angle_internal',
'action': [ 'python', 'action': [ 'vpython3',
'src/tests/restricted_traces/download_restricted_traces.py', 'src/tests/restricted_traces/download_restricted_traces.py',
'src/tests/restricted_traces', 'src/tests/restricted_traces',
] ]
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
import fnmatch import fnmatch
import json import json
import os import os
import subprocess
import sys import sys
...@@ -28,6 +29,19 @@ def read_json(json_file): ...@@ -28,6 +29,19 @@ def read_json(json_file):
return json.loads(map_file.read(), object_pairs_hook=reject_duplicate_keys) return json.loads(map_file.read(), object_pairs_hook=reject_duplicate_keys)
def run_command(command):
env = os.environ.copy()
env['PYTHONUNBUFFERED'] = '1'
with subprocess.Popen(
command, stdout=subprocess.PIPE, universal_newlines=True, env=env) as proc:
while proc.poll() is None:
out = proc.stdout.read(1)
sys.stdout.write(out)
sys.stdout.flush()
if proc.returncode:
raise subprocess.CalledProcessError(proc.returncode, cmd)
def main(): def main():
if (len(sys.argv) != 2): if (len(sys.argv) != 2):
print('Missing restricted traces directory') print('Missing restricted traces directory')
...@@ -36,8 +50,11 @@ def main(): ...@@ -36,8 +50,11 @@ def main():
trace_dir = sys.argv[1] trace_dir = sys.argv[1]
# issue download command # issue download command
download_script = 'download_from_google_storage'
if os.name == 'nt':
download_script += '.bat'
cmd = [ cmd = [
'download_from_google_storage', download_script,
'--directory', '--directory',
'--recursive', '--recursive',
'--extract', '--extract',
...@@ -46,7 +63,7 @@ def main(): ...@@ -46,7 +63,7 @@ def main():
trace_dir, trace_dir,
] ]
os.system(" ".join(cmd)) run_command(cmd)
json_file = os.path.join(trace_dir, 'restricted_traces.json') json_file = os.path.join(trace_dir, 'restricted_traces.json')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment