Under some conditions urlerror doesn't have a code,
authorDiane Trout <diane@caltech.edu>
Mon, 12 Jul 2010 19:01:31 +0000 (19:01 +0000)
committerDiane Trout <diane@caltech.edu>
Mon, 12 Jul 2010 19:01:31 +0000 (19:01 +0000)
so just report the raw error message in that case

htsworkflow/util/api.py

index b5e2492fef78c456ead6c68df03010a85adb8625..316aa490fd0ceaa67a4ed3712ad336f9519b3bbe 100644 (file)
@@ -83,11 +83,11 @@ def retrieve_info(url, apidata):
         apipayload = urllib.urlencode(apidata)
         web = urllib2.urlopen(url, apipayload)
     except urllib2.URLError, e:
-        if e.code == 404:
+        if hasattr(e, 'code') and e.code == 404:
             logging.info("%s was not found" % (url,))
             return None
         else:
-            errmsg = 'URLError: %d %s' % (e.code, e.msg)
+            errmsg = 'URLError: %s' % (str(e))
             raise IOError(errmsg)
     
     contents = web.read()