diff options
author | James Ennis <james.ennis@codethink.co.uk> | 2019-08-08 12:40:53 +0100 |
---|---|---|
committer | James Ennis <james.ennis@codethink.com> | 2019-08-09 07:48:17 +0000 |
commit | 13bd00da7308097d6b3d95788fcdc345f9166510 (patch) | |
tree | b52bdd7ea8f796a6b93d532c0c8387c1a79c3ced /src/buildstream/_frontend/cli.py | |
parent | 914568dd7790caa6ae5a0c1da3461b5b297fd92d (diff) | |
download | buildstream-jennis/fix_artifact_log.tar.gz |
Frontend: Fix bst artifact logjennis/fix_artifact_log
This command now fetches the absolute paths of the log files in
the local CAS cache and opens a pager for each path.
The test has also been updated to ensure that a log file is
actually obtained.
Diffstat (limited to 'src/buildstream/_frontend/cli.py')
-rw-r--r-- | src/buildstream/_frontend/cli.py | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py index 81ee4ad83..220d10477 100644 --- a/src/buildstream/_frontend/cli.py +++ b/src/buildstream/_frontend/cli.py @@ -1,8 +1,6 @@ import os import sys -from contextlib import ExitStack from functools import partial -from tempfile import TemporaryDirectory import fcntl import click @@ -1196,23 +1194,13 @@ def artifact_log(app, artifacts): # they are not somehow escaped. with app.initialized(): - logsdirs = app.stream.artifact_log(artifacts) - - with ExitStack() as stack: - extractdirs = [] - for logsdir in logsdirs: - # NOTE: If reading the logs feels unresponsive, here would be a good place - # to provide progress information. - td = stack.enter_context(TemporaryDirectory()) - logsdir.export_files(td, can_link=True) - extractdirs.append(td) - - for extractdir in extractdirs: - for log in (os.path.join(extractdir, log) for log in os.listdir(extractdir)): - # NOTE: Should click gain the ability to pass files to the pager this can be optimised. - with open(log) as f: - data = f.read() - click.echo_via_pager(data) + log_file_paths = app.stream.artifact_log(artifacts) + + for log in log_file_paths: + with open(log) as f: + data = f.read() + + click.echo_via_pager(data) ################################################################### |