diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-11-19 17:35:36 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-11-20 12:49:33 +0000 |
commit | cb4dde74da2c70a8c49c7c731182961b556c67ce (patch) | |
tree | fe02402495ec6eb52343cffae1f6947ccb3dd04a /baserockimport/mainloop.py | |
parent | 4e98f06721d91ed30aa06a9641ed71ab39ec34ff (diff) | |
download | import-cb4dde74da2c70a8c49c7c731182961b556c67ce.tar.gz |
Add --force-stratum-generation option
This should be useful when a couple of components raise errors but
you know that you don't need them anyway.
Diffstat (limited to 'baserockimport/mainloop.py')
-rw-r--r-- | baserockimport/mainloop.py | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/baserockimport/mainloop.py b/baserockimport/mainloop.py index 5574796..9c6e08b 100644 --- a/baserockimport/mainloop.py +++ b/baserockimport/mainloop.py @@ -182,14 +182,7 @@ class ImportLoop(object): current_item, current_item.dependencies, to_process, processed) - if len(errors) > 0: - self.app.status( - '\nErrors encountered, not generating a stratum morphology.') - self.app.status( - 'See the README files for guidance.') - else: - self._generate_stratum_morph_if_none_exists( - processed, self.goal_name) + self._maybe_generate_stratum(processed, errors, self.goal_name) duration = time.time() - start_time end_displaytime = time.strftime('%x %X %Z', time.localtime()) @@ -520,26 +513,43 @@ class ImportLoop(object): 'One or more cycles detected in build graph: %s' % (', '.join(all_loops_str))) - def _generate_stratum_morph_if_none_exists(self, graph, goal_name): + def _maybe_generate_stratum(self, graph, errors, goal_name): filename = os.path.join( self.app.settings['definitions-dir'], 'strata', '%s.morph' % goal_name) + update_existing = self.app.settings['update-existing'] - if os.path.exists(filename): - if not self.app.settings['update-existing']: - self.app.status( - msg='Found stratum morph for %s at %s, not overwriting' % - (goal_name, filename)) - return + if self.app.settings['force-stratum-generation']: + self._generate_stratum( + graph, goal_name, filename, ignore_errors=True) + elif len(errors) > 0: + self.app.status( + '\nErrors encountered, not generating a stratum morphology.') + self.app.status( + 'See the README files for guidance.') + elif os.path.exists(filename) and not update_existing: + self.app.status( + msg='Found stratum morph for %s at %s, not overwriting' % + (goal_name, filename)) + else: + self._generate_stratum(graph, goal_name, filename) + def _generate_stratum(self, graph, goal_name, filename, + ignore_errors=False): self.app.status(msg='Generating stratum morph for %s' % goal_name) chunk_entries = [] for package in self._sort_chunks_by_build_order(graph): m = package.morphology + if m is None: - raise cliapp.AppException('No morphology for %s' % package) + if ignore_errors: + logging.warn( + 'Ignoring %s because there is no chunk morphology.') + continue + else: + raise cliapp.AppException('No morphology for %s' % package) def format_build_dep(name, version): dep_package = find(graph, lambda p: p.match(name, version)) |