summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-09-04 14:03:28 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-09-11 13:26:27 +0100
commitcf0366c155d15008b8a309da1e974c06ec5ff9b5 (patch)
tree2a077fd7886b17bd6c3cb36bcbbcd74d4069126a
parent41a5ab4f699e24e342cb93ed9a99cbdbcc0f1974 (diff)
downloadmorph-cf0366c155d15008b8a309da1e974c06ec5ff9b5.tar.gz
import: Allow chunk morph generation to fail
Instead of exiting immediately, collect the errors up and report them at the end. The tool should do as much as possible on each execution. For example, this helps in the case where a user wants to get a rough idea of how much is involved to integrate a given package.
-rw-r--r--import/main.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/import/main.py b/import/main.py
index 08e8ecbd..b781f47a 100644
--- a/import/main.py
+++ b/import/main.py
@@ -385,7 +385,7 @@ class BaserockImportApplication(cliapp.Application):
to_process = [Package(goal_name, goal_version)]
processed = networkx.DiGraph()
- ignored_errors = []
+ errors = {}
while len(to_process) > 0:
current_item = to_process.pop()
@@ -404,18 +404,14 @@ class BaserockImportApplication(cliapp.Application):
chunk_morph = self.find_or_create_chunk_morph(
morph_set, goal_name, kind, name, checked_out_version,
source_repo, url, ref)
- except BaserockImportException as e:
- #logging.warning('Ignoring error %r and continuing!', e)
- #ignored_errors.append(name)
- sys.stderr.write(
- "Couldn't auto-generate a chunk morphology for %s, "
- "please provide one manually and continue.\n" % name)
- raise
- current_item.set_morphology(chunk_morph)
+ current_item.set_morphology(chunk_morph)
- build_deps = chunk_morph['x-build-dependencies-%s' % kind]
- runtime_deps = chunk_morph['x-runtime-dependencies-%s' % kind]
+ build_deps = chunk_morph['x-build-dependencies-%s' % kind]
+ runtime_deps = chunk_morph['x-runtime-dependencies-%s' % kind]
+ except BaserockImportException as e:
+ errors[current_item] = e
+ build_deps = runtime_deps = {}
processed.add_node(current_item)
@@ -428,11 +424,15 @@ class BaserockImportApplication(cliapp.Application):
current_item)
raise
- if len(ignored_errors) > 0:
- sys.stderr.write('Ignored errors in %i packages: %s\n' %
- (len(ignored_errors), ', '.join(ignored_errors)))
-
- self.maybe_generate_stratum_morph(processed, goal_name)
+ if len(errors) > 0:
+ self.status(
+ 'Errors encountered, not generating a stratum morphology. You '
+ 'may want to manually create chunk morphologies for the '
+ 'following items, then rerun the script.')
+ for package, exception in errors.iteritems():
+ self.status('%s: %s', package, exception)
+ else:
+ self.generate_stratum_morph_if_none_exists(processed, goal_name)
def generate_lorry_for_package(self, kind, name):
tool = '%s.to_lorry' % kind
@@ -561,7 +561,7 @@ class BaserockImportApplication(cliapp.Application):
return morphology
- def maybe_generate_stratum_morph(self, graph, goal_name):
+ def generate_stratum_morph_if_none_exists(self, graph, goal_name):
filename = os.path.join(
self.settings['definitions-dir'], 'strata', '%s.morph' % goal_name)