diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2015-06-01 14:14:41 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2015-06-05 12:54:45 +0000 |
commit | d873baa12f36e07e3f6d3b7f808d7f2f10763605 (patch) | |
tree | f196145d42a0183f6b3430b8834e69bd3fc0d819 /morphlib/plugins/system_manifests_plugin.py | |
parent | 061834bd983909ccf37927f4c0c5dd4eca827040 (diff) | |
download | morph-d873baa12f36e07e3f6d3b7f808d7f2f10763605.tar.gz |
morphlib: Use new temp_dir helper context manager
Change-Id: Ie4e024a63f2ab1c7ea66f2cbedaef99c9adf5e69
Diffstat (limited to 'morphlib/plugins/system_manifests_plugin.py')
-rw-r--r-- | morphlib/plugins/system_manifests_plugin.py | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/morphlib/plugins/system_manifests_plugin.py b/morphlib/plugins/system_manifests_plugin.py index cc26e5ca..8e14d2eb 100644 --- a/morphlib/plugins/system_manifests_plugin.py +++ b/morphlib/plugins/system_manifests_plugin.py @@ -134,34 +134,33 @@ class SystemManifestsPlugin(cliapp.Plugin): trove_id = self.app.settings['trove-id'][0] except IndexError: trove_id = None - tempdir = tempfile.mkdtemp(dir=self.app.settings['tempdir']) - lorries = get_lorry_repos(tempdir, self.lrc, self.app.status, - trove_id, self.app.settings['trove-host']) - manifest = Manifest(system_artifact.name, tempdir, self.app.status, - self.lrc) - - old_prefix = self.app.status_prefix - sources = set(a.source for a in system_artifact.walk() - if a.source.morphology['kind'] == 'chunk' - and a.source.morphology['build-mode'] != 'bootstrap') - for i, source in enumerate(sources, start=1): - source.cache_key = ckc.compute_key(source) - source.cache_id = ckc.get_cache_id(source) - name = source.morphology['name'] - ref = source.original_ref - - # Ensure we have a cache of the repo - if not self.lrc.has_repo(source.repo_name): - self.lrc.cache_repo(source.repo_name) - - cached = self.lrc.get_repo(source.repo_name) - - new_prefix = '[%d/%d][%s] ' % (i, len(sources), name) - self.app.status_prefix = old_prefix + new_prefix - manifest.add_chunk(self.app, name, source.repo_name, ref, cached, - resolver, lorries) - self.app.status_prefix = old_prefix - shutil.rmtree(tempdir) + with morphlib.util.temp_dir(dir=self.app.settings['tempdir']) as td: + lorries = get_lorry_repos(td, self.lrc, self.app.status, trove_id, + self.app.settings['trove-host']) + manifest = Manifest(system_artifact.name, td, self.app.status, + self.lrc) + + old_prefix = self.app.status_prefix + sources = set(a.source for a in system_artifact.walk() + if a.source.morphology['kind'] == 'chunk' + and a.source.morphology['build-mode'] != 'bootstrap') + for i, source in enumerate(sources, start=1): + source.cache_key = ckc.compute_key(source) + source.cache_id = ckc.get_cache_id(source) + name = source.morphology['name'] + ref = source.original_ref + + # Ensure we have a cache of the repo + if not self.lrc.has_repo(source.repo_name): + self.lrc.cache_repo(source.repo_name) + + cached = self.lrc.get_repo(source.repo_name) + + new_prefix = '[%d/%d][%s] ' % (i, len(sources), name) + self.app.status_prefix = old_prefix + new_prefix + manifest.add_chunk(self.app, name, source.repo_name, ref, + cached, resolver, lorries) + self.app.status_prefix = old_prefix def run_licensecheck(filename): |