From: Diane Trout Date: Mon, 12 Jul 2010 19:01:31 +0000 (+0000) Subject: Under some conditions urlerror doesn't have a code, X-Git-Tag: 0.4.4~6 X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=325826e214982bae30b86912628897ec9a8af0c7 Under some conditions urlerror doesn't have a code, so just report the raw error message in that case --- diff --git a/htsworkflow/util/api.py b/htsworkflow/util/api.py index b5e2492..316aa49 100644 --- a/htsworkflow/util/api.py +++ b/htsworkflow/util/api.py @@ -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()