self.config_parser.set('web','cgiuri','https://www.realraum.at/cgi/status.cgi?pass=jako16&set=')
#~ self.config_parser.set('web','htmlopen','<html><body bgcolor="lime"><center><b>Tür ist Offen</b></center></body></html>')
#~ self.config_parser.set('web','htmlclosed','<html><body bgcolor="red"><b><center>Tür ist Geschlossen</center></b></body></html>')
+ self.config_parser.set('web','htmlbored','<html><body bgcolor="lime"><center><b>Panic! Present&Bored</b></center></body></html>')
self.config_parser.set('web','htmlopen','<html><body bgcolor="lime"><center><b>Leute Anwesend</b></center></body></html>')
self.config_parser.set('web','htmlclosed','<html><body bgcolor="red"><b><center>Keiner Da</center></b></body></html>')
self.config_parser.add_section('debug')
def displayClosed():
setRealraumHtmlStatus(uwscfg.web_htmlclosed)
-
+
+def displayPanic():
+ setRealraumHtmlStatus(uwscfg.web_htmlbored)
+
def exitHandler(signum, frame):
logging.info("Update-Web-Status stopping")
try:
uwscfg = UWSConfig()
#socket.setdefaulttimeout(10.0) #affects all new Socket Connections (urllib as well)
-RE_STATUS = re.compile(r'Status: (people present|room empty)')
+RE_PRESENCE = re.compile(r'Presence: (yes|no)(?:, (opened|closed), (.+))?')
+RE_BUTTON = re.compile(r'PanicButton|button\d?')
while True:
try:
if not os.path.exists(uwscfg.tracker_socket):
conn = os.fdopen(sockhandle.fileno())
#sockhandle.send("listen\n")
#sockhandle.send("status\n")
+ last_status=None
+ unixts_panic_button=None
while True:
line = conn.readline()
logging.debug("Got Line: " + line)
if line == "":
raise Exception("EOF on Socket, daemon seems to have quit")
- m = RE_STATUS.match(line)
+ m = RE_PRESENCE.match(line)
if not m is None:
status = m.group(1)
- if status == "people present":
+ last_status=(status == "yes")
+ unixts_panic_button=None
+ if last_status:
+ displayOpen()
+ else:
+ displayClosed()
+ continue
+
+ m = RE_BUTTON.match(line)
+ if not m is None:
+ displayPanic()
+ unixts_panic_button=time.time()
+ continue
+
+ if not last_status is None and not unixts_panic_button is None and time.time() - unixts_panic_button > 3600:
+ unixts_panic_button=None
+ if last_status:
displayOpen()
- if status == "room empty":
+ else:
displayClosed()
+ continue
+
except Exception, ex:
logging.error("main: "+str(ex))
try: