warnings.warn("Performing download of %s" % url, stacklevel=5)
return urllib2.urlopen(url)
- def get(self, **params):
- "Get the XML response for the passed `params`."
- params['api_key'] = self._apiKey
- params['format'] = 'json'
- params['api_sig'] = self._sign(params)
-
- connection = self.open_url(SERVICE_URL, params)
-
+ @staticmethod
+ def read(connection, timeout):
# It appears that urllib uses the non-blocking variant of file objects
# which means reads might not always be complete, so grabbing as much
# of the data as possible with a sleep in between to give it more time
# to grab data.
+ contentLengthField = "Content-Length"
+
chunks = []
chunk = connection.read()
while chunk:
len(json),
)
+ return json
+
+ def get(self, **params):
+ "Get the XML response for the passed `params`."
+ params['api_key'] = self._apiKey
+ params['format'] = 'json'
+ params['api_sig'] = self._sign(params)
+
+ connection = self.open_url(SERVICE_URL, params)
+ json = self.read(connection, 5)
+
data = DottedDict('ROOT', parse_json(json))
rsp = data.rsp