Mercurial > code > home > repos > homeauto
comparison service/frontDoorMessage/frontDoorMessage.py @ 829:772b2065fca8
front door callbacks
Ignore-this: 1b5a7c53b1e40a24328d055bf1b51f86
darcs-hash:20120304114426-312f9-3495148e3b2043bd651e31ac6f31d68cc0b4c121.gz
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sun, 04 Mar 2012 03:44:26 -0800 |
parents | bc9ac10032f7 |
children |
comparison
equal
deleted
inserted
replaced
828:a422d875d94d | 829:772b2065fca8 |
---|---|
8 sys.path.append("/my/proj/homeauto/lib") | 8 sys.path.append("/my/proj/homeauto/lib") |
9 from cycloneerr import PrettyErrorHandler | 9 from cycloneerr import PrettyErrorHandler |
10 from logsetup import log | 10 from logsetup import log |
11 | 11 |
12 class LcdParts(object): | 12 class LcdParts(object): |
13 def __init__(self, putUrl): | 13 def __init__(self, putUrl, pingUrl): |
14 self.putUrl = putUrl | 14 self.putUrl, self.pingUrl = putUrl, pingUrl |
15 log.info("restarting- message is now empty") | 15 log.info("restarting- message is now empty") |
16 self.message = "" | 16 self.message = "" |
17 self.lastLine = "" | 17 self.lastLine = "" |
18 | 18 |
19 def updateLcd(self): | 19 def updateLcd(self): |
23 method="PUT", | 23 method="PUT", |
24 body=whole, | 24 body=whole, |
25 headers={"content-type":"text/plain"}) | 25 headers={"content-type":"text/plain"}) |
26 except socket.error, e: | 26 except socket.error, e: |
27 log.warn("update lcd failed, %s" % e) | 27 log.warn("update lcd failed, %s" % e) |
28 | |
29 try: | |
30 restkit.request(url=self.pingUrl, method="POST", body="") | |
31 except socket.error, e: | |
32 log.warn("ping failed, %s" % e) | |
28 | 33 |
29 class Index(PrettyErrorHandler, cyclone.web.RequestHandler): | 34 class Index(PrettyErrorHandler, cyclone.web.RequestHandler): |
30 @inlineCallbacks | 35 @inlineCallbacks |
31 def get(self): | 36 def get(self): |
32 | 37 |
71 | 76 |
72 if __name__ == '__main__': | 77 if __name__ == '__main__': |
73 | 78 |
74 config = { | 79 config = { |
75 'frontDoorArduino': "http://slash:9080/", | 80 'frontDoorArduino': "http://slash:9080/", |
76 'doorChangePost' : 'http://bang.bigasterisk.com:9069/inputChange', | 81 'doorChangePost' : 'http://bang:8014/frontDoorChange', |
77 'servePort' : 9081, | 82 'servePort' : 9081, |
78 } | 83 } |
79 | 84 |
80 lcdParts = LcdParts(config['frontDoorArduino'] + 'lcd') | 85 lcdParts = LcdParts(config['frontDoorArduino'] + 'lcd', |
86 config['doorChangePost']) | |
81 | 87 |
82 reactor.listenTCP(config['servePort'], Application(lcdParts)) | 88 reactor.listenTCP(config['servePort'], Application(lcdParts)) |
83 reactor.run() | 89 reactor.run() |