api: Generically convert non-string values to JSON in python bindings
(imported from commit 820bc20d469832b5785b434726c81e59a3f67ea5)
This commit is contained in:
parent
c38587191e
commit
18cefd37a8
|
@ -27,6 +27,11 @@ class HumbugAPI():
|
|||
request["api-key"] = self.api_key
|
||||
request["client"] = self.client_name
|
||||
request["failures"] = 0
|
||||
|
||||
for (key, val) in request.iteritems():
|
||||
if not (isinstance(val, str) or isinstance(val, unicode)):
|
||||
request[key] = simplejson.dumps(val)
|
||||
|
||||
while True:
|
||||
try:
|
||||
res = requests.post(urlparse.urljoin(self.base_url, url), data=request,
|
||||
|
@ -101,8 +106,7 @@ class HumbugAPI():
|
|||
return self.do_api_query(request, "/api/v1/get_subscriptions")
|
||||
|
||||
def subscribe(self, streams):
|
||||
request = {}
|
||||
request["streams"] = simplejson.dumps(streams)
|
||||
request = {'streams': streams}
|
||||
return self.do_api_query(request, "/api/v1/subscribe")
|
||||
|
||||
def call_on_each_message(self, callback, options = {}):
|
||||
|
|
Loading…
Reference in a new issue