[jhbuild] Handle KeyError exception on rdepends command
- From: Craig Keogh <cskeogh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild] Handle KeyError exception on rdepends command
- Date: Sun, 9 Jan 2011 10:43:20 +0000 (UTC)
commit cb1f69a815d8dccca880a7a70d272d0712fdb294
Author: Craig Keogh <cskeogh adam com au>
Date: Fri Jan 7 20:55:40 2011 +1030
Handle KeyError exception on rdepends command
If a listed dependency doesn't exist, 'jhbuild rdepend' can bomb with a
stack trace. Now, the problematic dependency is displayed via info. This
leads to many infos with the current untidy 3.0 modulesets.
jhbuild/commands/rdepends.py | 4 +++-
jhbuild/moduleset.py | 20 +++++++++++++++++---
2 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/jhbuild/commands/rdepends.py b/jhbuild/commands/rdepends.py
index 5767403..8f99ef3 100644
--- a/jhbuild/commands/rdepends.py
+++ b/jhbuild/commands/rdepends.py
@@ -67,7 +67,9 @@ class cmd_rdepends(Command):
if modname in module.dependencies:
uprint(module.name)
else:
- module_list = module_set.get_module_list([module.name], ignore_cycles=True)
+ module_list = module_set.get_module_list([module.name],
+ ignore_cycles=True,
+ ignore_missing=True)
if modname in [x.name for x in module_list]:
seen_modules.append(module.name)
deps = ''
diff --git a/jhbuild/moduleset.py b/jhbuild/moduleset.py
index 2adbe1b..6bac640 100644
--- a/jhbuild/moduleset.py
+++ b/jhbuild/moduleset.py
@@ -82,6 +82,7 @@ class ModuleSet:
# otherwise be built
i = 0
while i < len(all_modules):
+ dep_missing = False
for modname in all_modules[i].dependencies:
depmod = self.modules.get(modname)
if not depmod:
@@ -90,7 +91,11 @@ class ModuleSet:
'%(module)s has a dependency on unknown "%(invalid)s" module') % {
'module': all_modules[i].name,
'invalid': modname})
- del all_modules[i]
+ logging.info(_(
+ '%(module)s has a dependency on unknown "%(invalid)s" module') % {
+ 'module': all_modules[i].name,
+ 'invalid': modname})
+ dep_missing = True
continue
if not depmod in all_modules:
all_modules.append(depmod)
@@ -103,6 +108,10 @@ class ModuleSet:
continue
if not depmod in all_modules:
all_modules.append(depmod)
+
+ if dep_missing:
+ del all_modules[i]
+
i += 1
# 2nd: order them, raise an exception on hard dependency cycle, ignore
@@ -136,8 +145,11 @@ class ModuleSet:
return
self._state[module] = 'in-progress'
for modname in module.dependencies:
- depmod = self.modules[modname]
- order([self.modules[x] for x in depmod.dependencies], depmod, 'dependencies')
+ try:
+ depmod = self.modules[modname]
+ order([self.modules[x] for x in depmod.dependencies], depmod, 'dependencies')
+ except KeyError:
+ pass # user already notified via logging.info above
if not ignore_suggests:
for modname in module.suggests:
depmod = self.modules.get(modname)
@@ -148,6 +160,8 @@ class ModuleSet:
order([self.modules[x] for x in depmod.dependencies], depmod, 'suggests')
except DependencyCycleError:
self._state, self._ordered = save_state, save_ordered
+ except KeyError:
+ pass # user already notified via logging.info above
extra_afters = []
for modname in module.after:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]