diff py/uploader.py @ 231:e39ed85d87a5

fix a few python3 issues
author Matt Johnston <matt@ucc.asn.au>
date Sat, 11 Apr 2015 00:16:05 +0800
parents 185621f47040
children 19569cb5ed46
line wrap: on
line diff
--- a/py/uploader.py	Fri Apr 10 23:59:16 2015 +0800
+++ b/py/uploader.py	Sat Apr 11 00:16:05 2015 +0800
@@ -44,8 +44,8 @@
     @asyncio.coroutine
     def send(self, tosend):
         js = json.dumps(tosend)
-        js_enc = binascii.b2a_base64(zlib.compress(js))
-        mac = hmac.new(config.HMAC_KEY, js_enc).hexdigest()
+        js_enc = binascii.b2a_base64(zlib.compress(js.encode()))
+        mac = hmac.new(config.HMAC_KEY.encode(), js_enc).hexdigest()
         send_data = {'data': js_enc, 'hmac': mac}
         r = yield from asyncio.wait_for(aiohttp.request('post', config.UPDATE_URL, data=send_data), 60)
         result = yield from asyncio.wait_for(r.text(), 60)
@@ -62,7 +62,7 @@
             readings = None
             D("Sent updated %d readings" % nreadings)
         except Exception as e:
-            EX("Error in uploader: %s" % str(e))
+            E("Error in uploader: %s" % str(e))
         finally:
             if readings is not None:
                 self.server.pushfront(readings)