changeset 530:73257bae83ea

fix a few python3 issues
author Matt Johnston <matt@ucc.asn.au>
date Sat, 11 Apr 2015 00:16:05 +0800
parents 5201f441bf4a
children fd0fd9f947a1
files py/gpio_test.py py/params.py py/tempserver.py py/uploader.py
diffstat 4 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/py/gpio_test.py	Fri Apr 10 23:59:16 2015 +0800
+++ b/py/gpio_test.py	Sat Apr 11 00:16:05 2015 +0800
@@ -14,7 +14,7 @@
 	def turn(self, value):
 		self.state = bool(value)
 		onoff = ("off", "on")[int(self.state)]
-		L("Test GPIO %s pin %d turned %s" % (self.name, self.pin, onoff))
+		L("Test GPIO %s pin %s turned %s" % (self.name, self.pin, onoff))
 
 	def get_state(self):
 		return self.state
--- a/py/params.py	Fri Apr 10 23:59:16 2015 +0800
+++ b/py/params.py	Sat Apr 11 00:16:05 2015 +0800
@@ -36,7 +36,7 @@
     def load(self, f = None):
         if not f:
             try:
-                f = file(config.PARAMS_FILE, 'r')
+                f = open(config.PARAMS_FILE, 'r')
             except IOError as e:
                 W("Missing parameter file, using defaults. %s", e)
                 return
--- a/py/tempserver.py	Fri Apr 10 23:59:16 2015 +0800
+++ b/py/tempserver.py	Sat Apr 11 00:16:05 2015 +0800
@@ -14,7 +14,7 @@
 from utils import L,D,EX,W
 import fridge
 import config
-import sensor_ds18b20
+import sensor
 import params
 import uploader
 
--- 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)