[yocto] [opkg-utils][PATCH 15/22] opkg.py: catch TypeError when reading control file, to show which one is failing

Martin Jansa martin.jansa at gmail.com
Thu Mar 29 15:22:49 PDT 2012


Signed-off-by: Martin Jansa <Martin.Jansa at gmail.com>
---
 opkg.py |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/opkg.py b/opkg.py
index 856e057..299e84e 100644
--- a/opkg.py
+++ b/opkg.py
@@ -161,7 +161,10 @@ class Package:
                 control = tarf.extractfile("control")
             except KeyError:
                 control = tarf.extractfile("./control")
-            self.read_control(control)
+            try:
+                self.read_control(control)
+            except TypeError as e:
+                sys.stderr.write("Cannot read control file '%s' - %s\n" % (fn, e))
             control.close()
 
         self.scratch_dir = None
@@ -457,9 +460,13 @@ class Packages:
 
     def read_packages_file(self, fn):
         f = open(fn, "r")
-        while 1:
+        while True:
             pkg = Package()
-            pkg.read_control(f)
+            try:
+                pkg.read_control(f)
+            except TypeError as e:
+                sys.stderr.write("Cannot read control file '%s' - %s\n" % (fn, e))
+                continue
             if pkg.get_package():
                 self.add_package(pkg)
             else:
-- 
1.7.8.5




More information about the yocto mailing list