TransRead: catch ValueError exceptions
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Fri, 4 Jan 2013 14:46:31 +0000 (16:46 +0200)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Fri, 4 Jan 2013 14:46:31 +0000 (16:46 +0200)
Sometimes urllib2 throws ValueError exceptions when it cannot open a local
file. Catch it as well.

Change-Id: I1f5707ad37d079368a2bf4b3ed3d092c43064387
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
bmaptools/TransRead.py

index 51192c7..c4d19d1 100644 (file)
@@ -206,7 +206,7 @@ class TransRead:
                     opener.addheaders = [('User-Agent', 'Mozilla/5.0')]
                     urllib2.install_opener(opener)
                     self._file_obj = opener.open(filepath)
-                except IOError as err:
+                except (IOError, ValueError) as err:
                     raise Error("cannot open URL '%s': %s" % (filepath, err))
 
                 self.is_url = True