33
33
- uses standard Python json lib
34
34
"""
35
35
36
- try :
37
- import http .client as httplib
38
- except ImportError :
39
- import httplib
40
36
import base64
41
37
import decimal
38
+ import http .client
42
39
import json
43
40
import logging
44
41
import socket
45
42
import time
46
- try :
47
- import urllib .parse as urlparse
48
- except ImportError :
49
- import urlparse
43
+ import urllib .parse
50
44
51
45
USER_AGENT = "AuthServiceProxy/0.1"
52
46
@@ -60,7 +54,7 @@ def __init__(self, rpc_error):
60
54
errmsg = '%(message)s (%(code)i)' % rpc_error
61
55
except (KeyError , TypeError ):
62
56
errmsg = ''
63
- Exception .__init__ (self , errmsg )
57
+ super () .__init__ (errmsg )
64
58
self .error = rpc_error
65
59
66
60
@@ -77,7 +71,7 @@ def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connect
77
71
self .__service_url = service_url
78
72
self ._service_name = service_name
79
73
self .ensure_ascii = ensure_ascii # can be toggled on the fly by tests
80
- self .__url = urlparse .urlparse (service_url )
74
+ self .__url = urllib . parse .urlparse (service_url )
81
75
if self .__url .port is None :
82
76
port = 80
83
77
else :
@@ -98,10 +92,10 @@ def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connect
98
92
# Callables re-use the connection of the original proxy
99
93
self .__conn = connection
100
94
elif self .__url .scheme == 'https' :
101
- self .__conn = httplib .HTTPSConnection (self .__url .hostname , port ,
95
+ self .__conn = http . client .HTTPSConnection (self .__url .hostname , port ,
102
96
timeout = timeout )
103
97
else :
104
- self .__conn = httplib .HTTPConnection (self .__url .hostname , port ,
98
+ self .__conn = http . client .HTTPConnection (self .__url .hostname , port ,
105
99
timeout = timeout )
106
100
107
101
def __getattr__ (self , name ):
@@ -124,7 +118,7 @@ def _request(self, method, path, postdata):
124
118
try :
125
119
self .__conn .request (method , path , postdata , headers )
126
120
return self ._get_response ()
127
- except httplib .BadStatusLine as e :
121
+ except http . client .BadStatusLine as e :
128
122
if e .line == "''" : # if connection was closed, try again
129
123
self .__conn .close ()
130
124
self .__conn .request (method , path , postdata , headers )
0 commit comments