diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2017-11-06 16:57:32 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2017-11-06 16:57:32 +0000 |
commit | e187ec0e25b398619ede835df614dadf69618423 (patch) | |
tree | 4cbebc4da710aa2057c2dadabe8e3b30e9a49ccf /buildstream/_pipeline.py | |
parent | 0f134712d3efb31cd1e3d53d464a8e66ee92a5f1 (diff) | |
download | buildstream-sam/bst-checkout-metadata.tar.gz |
Allow checking out artifact metadata with `bst checkout`sam/bst-checkout-metadata
This commit adds a new `bst checkout --metadata` mode which checks out
the artifact's build logs and metadata into a user specified directory.
This is instead of the normal mode which checks out and optionally
integrates the artifact's contents.
Diffstat (limited to 'buildstream/_pipeline.py')
-rw-r--r-- | buildstream/_pipeline.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py index 90ed899ea..aa0299c52 100644 --- a/buildstream/_pipeline.py +++ b/buildstream/_pipeline.py @@ -490,6 +490,38 @@ class Pipeline(): except OSError as e: raise PipelineError("Failed to copy files: {}".format(e)) from e + # checkout_metadata() + # + # Checkout the metadata from the pipeline target artifact to the specified directory + # + # Args: + # directory (str): The directory to checkout the artifact to + # force (bool): Force overwrite files which exist in `directory` + # + def checkout_metadata(self, directory, force): + # We only have one target in a checkout command + target = self.targets[0] + + try: + os.makedirs(directory, exist_ok=True) + except OSError as e: + raise PipelineError("Failed to create metadata checkout directory: {}".format(e)) from e + + if not os.access(directory, os.W_OK): + raise PipelineError("Directory {} not writable".format(directory)) + + if not force and os.listdir(directory): + raise PipelineError("Checkout directory is not empty: {}" + .format(directory)) + + metadata_dirs = target.metadata_dirs() + with target.timed_activity("Copying metadata files to {}".format(directory)): + for metadata_type, metadata_dir in metadata_dirs.items(): + try: + utils.copy_files(metadata_dir, os.path.join(directory, metadata_type)) + except OSError as e: + raise PipelineError("Failed to copy files: {}".format(e)) from e + # open_workspace # # Open a project workspace. |