Closed guandalf closed 12 years ago
Can you try this snippet?
import urllib2
>>> try:
... x = urllib2.urlopen('http://google.com/error')
... except Exception as e:
... x = e
...
>>> type(e)
<class 'urllib2.HTTPError'>
>>> x.headers
<httplib.HTTPMessage instance at 0x10069a7a0>
I can't understand why your call with an "Error" response creates an instance of urllib2.HTTPError
without the attribute headers
.
Plz curl -v
your call.
Thx
(kanbanizesync)guandalf@earth:~/Virtualenv/kanbanizesync$ python Python 2.7.3 (default, Apr 20 2012, 22:39:59) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import urllib2 try: ... x = urllib2.urlopen('http://google.com/error') ... except Exception as e: ... x = e ... type(e) <class 'urllib2.HTTPError'> x.headers <httplib.HTTPMessage instance at 0x14921b8>
On Thu, Jun 28, 2012 at 7:21 PM, Andrea de Marco < reply@reply.github.com
wrote:
Can you try this snippet?
import urllib2 >>> try: ... x = urllib2.urlopen('http://google.com/error') ... except Exception as e: ... x = e ... >>> type(e) <class 'urllib2.HTTPError'> >>> x.headers <httplib.HTTPMessage instance at 0x10069a7a0>
I can't understand why your call with an "Error" response creates an instance of
urllib2.HTTPError
without the attributeheaders
.Plz
curl -v
your call.Thx
Reply to this email directly or view it on GitHub: https://github.com/z4r/python-rtkit/issues/7#issuecomment-6635875
guandalf
He is a very modest man with a great deal to be modest about. More quotes from Winston Churchill http://www.quotedb.com/authors/winston-churchill
So, we have to curl -v
your original call.
ATM i can't re-produce it.
@guandalf were you able to fix this bug? I have exactly the same error.
@morallo I haven't worked on it anymore. Sorry.
(kanbanizesync)guandalf@earth:~/Workspace/kanbanizesync/src$ python kize2rt.py [DEBUG] POST search/ticket?orderby=%2Bid&query=%28Status+%3D+%27open%27+OR+Status+%3D+%27new%27+OR+Status+%3D+%27stalled%27%29+AND+%28Queue+%3D+%27qaupdate%27%29&format=s [DEBUG] {'Accept': 'text/plain'} [DEBUG] None Traceback (most recent call last): File "kize2rt.py", line 35, in
rt_all_tickets = rt.post(path='search/ticket?%s' % params)
File "/home/guandalf/Virtualenv/kanbanizesync/local/lib/python2.7/site-packages/rtkit/resource.py", line 20, in post
return self.request('POST', path, payload, headers)
File "/home/guandalf/Virtualenv/kanbanizesync/local/lib/python2.7/site-packages/rtkit/resource.py", line 39, in request
return self.response_cls(req, response)
File "/home/guandalf/Virtualenv/kanbanizesync/local/lib/python2.7/site-packages/rtkit/resource.py", line 48, in init
self.headers = response.headers
AttributeError: 'HTTPError' object has no attribute 'headers'
Betrayed by urllib2? Try "requests" :)