diff py/sensor_test.py @ 531:fd0fd9f947a1

improve exception handling
author Matt Johnston <matt@ucc.asn.au>
date Sat, 11 Apr 2015 21:09:13 +0800
parents 5201f441bf4a
children
line wrap: on
line diff
--- a/py/sensor_test.py	Sat Apr 11 00:16:05 2015 +0800
+++ b/py/sensor_test.py	Sat Apr 11 21:09:13 2015 +0800
@@ -11,7 +11,7 @@
     def make_vals(self):
         def try_read(f, fallback):
             try:
-                return open(f, 'r').read()
+                return float(open(f, 'r').read())
             except Exception as e:
                 return fallback
 
@@ -22,7 +22,6 @@
         return vals
 
     def run(self):
-
         while True:
             yield from asyncio.sleep(1)
             vals = self.make_vals()