Skip to content

Commit

Permalink
Add support for Python 2.7, which has a vastly different xmlrpclib.
Browse files Browse the repository at this point in the history
  • Loading branch information
bhearsum committed Jul 30, 2013
1 parent 95a400e commit 859f565
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pyzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,17 @@ def info(self):
# creating a cookie jar for my cookies
cj = cookielib.LWPCookieJar()
self.send_content(h, request_body)
errcode, errmsg, headers = h.getreply()
try:
# In Python <= 2.6, h is an HTTP object, which has a nice
# "getreply" method.
errcode, errmsg, headers = h.getreply()
except AttributeError:
# In other reasons we have an HTTPConnection, which has a
# different interface
resp = h.getresponse()
errcode = resp.status
errmsg = resp.reason
headers = resp.msg
cresponse = CookieResponse(headers)
cj.extract_cookies(cresponse, crequest)
if len(cj) >0 and not os.path.exists(self.cookiefile):
Expand All @@ -88,9 +98,10 @@ def info(self):
self.verbose = verbose
try:
sock = h._conn.sock
return self._parse_response(h.getfile(), sock)
except AttributeError:
sock = None
return self._parse_response(h.getfile(), sock)
return self.parse_response(resp)

class BugZilla(xmlrpclib.Server):
def __init__(self, url, verbose = False, cookiefile = None,
Expand Down

0 comments on commit 859f565

Please sign in to comment.