diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-12-20 18:54:01 -0500 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-12-20 18:59:34 -0500 |
commit | b593b5147c3b2887c90866c51de668072cfa4f4e (patch) | |
tree | 7ba41edfc55478fbfdbc7f3555c0469394461494 | |
parent | 1495ff931035011543c67fa0fd4e891373c63554 (diff) | |
download | buildstream-b593b5147c3b2887c90866c51de668072cfa4f4e.tar.gz |
plugins/sources/tar.py: Dont manually reraise exception
It's not required to raise SourceError() manually when calling
utils.get_host_tool().
-rw-r--r-- | buildstream/plugins/sources/tar.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/buildstream/plugins/sources/tar.py b/buildstream/plugins/sources/tar.py index f432a5148..c5f8a7d31 100644 --- a/buildstream/plugins/sources/tar.py +++ b/buildstream/plugins/sources/tar.py @@ -67,21 +67,20 @@ class TarSource(DownloadableFileSource): self.node_validate(node, DownloadableFileSource.COMMON_CONFIG_KEYS + ['base-dir']) def preflight(self): + self.host_lzip = None if self.url.endswith('.lz'): - try: - utils.get_host_tool('lzip') - except utils.ProgramNotFoundError: - raise SourceError('File "{}" requires "lzip" tool on host which is missing'.format(self.url)) + self.host_lzip = utils.get_host_tool('lzip') def get_unique_key(self): return super().get_unique_key() + [self.base_dir] @contextmanager def _run_lzip(self): + assert(self.host_lzip) with TemporaryFile() as lzip_stdout: with ExitStack() as context: lzip_file = context.enter_context(open(self._get_mirror_file(), 'r')) - self.call(['lzip', '-d'], + self.call([self.host_lzip, '-d'], stdin=lzip_file, stdout=lzip_stdout) |