Mercurial > code > home > repos > homeauto
comparison service/starArduino/starArduino.py @ 90:80efeab5c02f
fix broken request paths
Ignore-this: dbfef5f7358cf2b89dc58dd3c377041c
author | drewp@bigasterisk.com |
---|---|
date | Fri, 16 Aug 2013 22:54:53 -0700 |
parents | 4e34fd9aee00 |
children | ca380454d176 |
comparison
equal
deleted
inserted
replaced
89:1c1fcb71e10a | 90:80efeab5c02f |
---|---|
4 """ | 4 """ |
5 from __future__ import division | 5 from __future__ import division |
6 | 6 |
7 import sys,json | 7 import sys,json |
8 from twisted.internet import reactor, task | 8 from twisted.internet import reactor, task |
9 from twisted.internet.task import LoopingCall | |
10 import cyclone.web, restkit | 9 import cyclone.web, restkit |
11 | 10 |
12 sys.path.append("/my/proj/pixel/shiftweb") | 11 sys.path.append("/my/proj/pixel/shiftweb") |
13 from drvarduino import ShiftbriteArduino | 12 from drvarduino import ShiftbriteArduino |
14 from shiftweb import hexFromRgb, rgbFromHex | 13 from shiftweb import hexFromRgb, rgbFromHex |
47 self.write("updated %r" % colors) | 46 self.write("updated %r" % colors) |
48 | 47 |
49 class Barcode(PrettyErrorHandler, cyclone.web.RequestHandler): | 48 class Barcode(PrettyErrorHandler, cyclone.web.RequestHandler): |
50 def get(self): | 49 def get(self): |
51 self.set_header("Content-Type", "text/plain") | 50 self.set_header("Content-Type", "text/plain") |
52 ser = self.settings.arduino.ser | 51 ard = self.settings.arduino |
53 ser.write("\x60\x02") | 52 ard.ser.write("\x60\x02") |
54 self.write(str(ser.readJson())) | 53 self.write(str(ard.readJson())) |
55 | 54 |
56 class BarcodeBeep(PrettyErrorHandler, cyclone.web.RequestHandler): | 55 class BarcodeBeep(PrettyErrorHandler, cyclone.web.RequestHandler): |
57 def put(self): | 56 def put(self): |
58 self.set_header("Content-Type", "text/plain") | 57 self.set_header("Content-Type", "text/plain") |
59 ser = self.settings.arduino.ser | 58 ard = self.settings.arduino |
60 ser.write("\x60\x03") | 59 ard.ser.write("\x60\x03") |
61 self.write(str(ser.readJson())) | 60 self.write(str(ard.readJson())) |
62 | 61 |
63 def barcodeWatch(arduino, postBarcode): | 62 def barcodeWatch(arduino, postBarcode): |
64 arduino.ser.write("\xff\xfb") | 63 arduino.ser.write("\xff\xfb") |
65 ret = arduino.readJson() | 64 ret = arduino.readJson() |
66 if not ret['barcode']: | 65 if not ret['barcode']: |