Fix up error handling for egencache --update-use-local-desc.
authorZac Medico <zmedico@gentoo.org>
Thu, 26 Aug 2010 19:46:35 +0000 (12:46 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 26 Aug 2010 19:46:35 +0000 (12:46 -0700)
bin/egencache
pym/repoman/utilities.py

index 4bfb5be8f20ec90d7b88a8d59e4e32c5673f8f93..515c6566dbcfc0dd5e2a8b6ed11e46ea8e2f055a 100755 (executable)
@@ -347,9 +347,16 @@ class GenUseLocalDesc(object):
                                        level=logging.ERROR, noiselevel=-1)
                                self.returncode |= 1
                        else:
-                               usedict = parse_metadata_use(metadata)
-                               for flag in sorted(usedict.keys()):
-                                       output.write('%s:%s - %s\n' % (cp, flag, usedict[flag]))
+                               try:
+                                       usedict = parse_metadata_use(metadata)
+                               except portage.exception.ParseError as e:
+                                       writemsg_level(
+                                               "ERROR: failed parsing %s/metadata.xml: %s\n" % (cp, e),
+                                               level=logging.ERROR, noiselevel=-1)
+                                       self.returncode |= 1
+                               else:
+                                       for flag in sorted(usedict.keys()):
+                                               output.write('%s:%s - %s\n' % (cp, flag, usedict[flag]))
 
                output.close()
 
index ed0de4449aef58287527c45b52334341c7f6f2aa..b2d17fc9a5102ec54398cef2d57b09816e3192cc 100644 (file)
@@ -131,11 +131,15 @@ def parse_metadata_use(xml_tree):
 
        for flag in flags:
                pkg_flag = flag.get("name")
-               pkg_flag_value = whitespace_re.sub(' ', flag.text).strip()
                if pkg_flag is None:
                        raise exception.ParseError("missing 'name' attribute for 'flag' tag")
+               if flag.text is None:
+                       raise exception.ParseError("missing USE description with " + \
+                               "the 'flag' tag (name=%s)" % pkg_flag)
+               pkg_flag_value = whitespace_re.sub(' ', flag.text).strip()
                if not pkg_flag_value:
-                       raise exception.ParseError("missing USE description with the 'flag' tag")
+                       raise exception.ParseError("missing USE description with " + \
+                               "the 'flag' tag (name=%s)" % pkg_flag)
                uselist[pkg_flag] = pkg_flag_value
        return uselist