summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-11-19 17:35:36 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-11-20 12:49:33 +0000
commitcb4dde74da2c70a8c49c7c731182961b556c67ce (patch)
treefe02402495ec6eb52343cffae1f6947ccb3dd04a
parent4e98f06721d91ed30aa06a9641ed71ab39ec34ff (diff)
downloadimport-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.
-rw-r--r--baserockimport/app.py5
-rw-r--r--baserockimport/mainloop.py42
2 files changed, 31 insertions, 16 deletions
diff --git a/baserockimport/app.py b/baserockimport/app.py
index 6ae3424..921d822 100644
--- a/baserockimport/app.py
+++ b/baserockimport/app.py
@@ -44,6 +44,11 @@ class BaserockImportApplication(cliapp.Application):
metavar="PATH",
default=os.path.abspath('./lorry-working-dir'))
+ self.settings.boolean(['force-stratum-generation', 'force-stratum'],
+ "always create a stratum, overwriting any "
+ "existing stratum morphology, and ignoring any "
+ "components where errors occurred during import",
+ default=False)
self.settings.boolean(['update-existing'],
"update all the checked-out Git trees and "
"generated definitions",
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))