From a84674d4acd374c1190633b94ceba6e9865352ec Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Sun, 7 Mar 2010 00:23:32 +0000 Subject: [PATCH] Panic/Bored Status --- update-web-status.py | 13 ++++++++++++- update-xmpp-status.py | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/update-web-status.py b/update-web-status.py index 1011461..a2e4beb 100755 --- a/update-web-status.py +++ b/update-web-status.py @@ -31,6 +31,7 @@ class UWSConfig: self.config_parser.set('web','cgiuri','https://www.realraum.at/cgi/status.cgi?pass=jako16&set=') #~ self.config_parser.set('web','htmlopen','
Tür ist Offen
') #~ self.config_parser.set('web','htmlclosed','
Tür ist Geschlossen
') + self.config_parser.set('web','htmlbored','
Panic! Present&Bored
') self.config_parser.set('web','htmlopen','
Leute Anwesend
') self.config_parser.set('web','htmlclosed','
Keiner Da
') self.config_parser.add_section('debug') @@ -165,7 +166,10 @@ def displayOpen(): def displayClosed(): setRealraumHtmlStatus(uwscfg.web_htmlclosed) - + +def displayPanic(): + setRealraumHtmlStatus(uwscfg.web_htmlbored) + def exitHandler(signum, frame): logging.info("Update-Web-Status stopping") try: @@ -193,6 +197,7 @@ else: #socket.setdefaulttimeout(10.0) #affects all new Socket Connections (urllib as well) #RE_STATUS = re.compile(r'Status: (\w+), idle') RE_PRESENCE = re.compile(r'Presence: (yes|no)') +RE_BUTTON = re.compile(r'button\d?') while True: try: if not os.path.exists(uwscfg.tracker_socket): @@ -220,6 +225,12 @@ while True: displayOpen() else: displayClosed() + continue + m = RE_BUTTON.match(line) + if not m is None: + displayPanic() + continue + except Exception, ex: logging.error("main: "+str(ex)) try: diff --git a/update-xmpp-status.py b/update-xmpp-status.py index 14c8007..04bd22c 100755 --- a/update-xmpp-status.py +++ b/update-xmpp-status.py @@ -33,6 +33,7 @@ class UWSConfig: self.config_parser.set('xmpp','recipients_normal','xro@jabber.tittelbach.at otti@wirdorange.org') self.config_parser.set('xmpp','recipients_nooffline','the-equinox@jabber.org') self.config_parser.add_section('msg') + self.config_parser.set('msg','bored',"Somebody is bored and in need of company. Go Visit !") self.config_parser.set('msg','format',"${status_msg}${request_msg}${comment_msg}") self.config_parser.set('msg','status_opened_msg',"RealRaum door now open") self.config_parser.set('msg','status_closed_msg',"RealRaum door now closed") @@ -268,6 +269,7 @@ distributeXmppMsg("update-xmpp-status.py started", debug=True) RE_STATUS = re.compile(r'Status: (\w+), idle') RE_REQUEST = re.compile(r'Request: (\w+) (?:Card )?(.+)') RE_PRESENCE = re.compile(r'Presence: (yes|no)') +RE_BUTTON = re.compile(r'button\d?') RE_ERROR = re.compile(r'Error: (.+)') while True: try: @@ -290,6 +292,10 @@ while True: if line == "": raise Exception("EOF on Socket, daemon seems to have quit") + m = RE_BUTTON.match(line) + if not m is None: + distributeXmppMsg(uwscfg.msg_bored) + continue m = RE_PRESENCE.match(line) if not m is None: formatAndDistributePresence(m.group(1)) -- 1.7.10.4