From ec263cff7a56d6955bf31fb17216bb888d43ba1e Mon Sep 17 00:00:00 2001 From: realraum Date: Thu, 10 Sep 2009 02:14:09 +0000 Subject: [PATCH] =?utf8?q?xmpp=20sendet=20user=20der=20tuer=20=C3=B6ffnet/sc?= =?utf8?q?hlie=C3=9Ft?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- update-web-status.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/update-web-status.py b/update-web-status.py index d6b5716..d8c3af9 100755 --- a/update-web-status.py +++ b/update-web-status.py @@ -18,8 +18,9 @@ url_open = 'https://www.realraum.at/cgi/status.cgi?pass=jako16&set=%3Chtml%3E%3C url_closed = 'https://www.realraum.at/cgi/status.cgi?pass=jako16&set=%3Chtml%3E%3Cbody%20bgcolor=%22red%22%3E%3Cb%3E%3Ccenter%3ET%26uuml%3Br%20ist%20Geschlossen%3C/center%3E%3C/b%3E%3C/body%3E%3C/html%3E' sendxmpp_recipients = 'xro@jabber.tittelbach.at otti@wirdorange.org' sendxmpp_cmd = 'sendxmpp -u realrauminfo -p 5SPjTdub -j jabber.tittelbach.at -r torwaechter -t ' -sendxmpp_msg_opened="Realraum Tür wurde geöffnet" -sendxmpp_msg_closed="Realraum Tür wurde geschlossen" +sendxmpp_msg_opened="Realraum Tür wurde%s geöffnet" +sendxmpp_msg_closed="Realraum Tür wurde%s geschlossen" +action_by="" def display_open(): try: @@ -32,7 +33,7 @@ def display_open(): try: logging.debug("Starting " + sendxmpp_cmd+sendxmpp_recipients) sppoo = subprocess.Popen(sendxmpp_cmd+sendxmpp_recipients,stdin=subprocess.PIPE,shell=True) - sppoo.communicate(input=sendxmpp_msg_opened+time.strftime(" (%Y-%m-%d %T)")) + sppoo.communicate(input=(sendxmpp_msg_opened % action_by)+time.strftime(" (%Y-%m-%d %T)")) sppoo.wait() logging.debug("XMPP Message about door opening sent") except: @@ -50,7 +51,7 @@ def display_closed(): try: logging.debug("Starting " + sendxmpp_cmd+sendxmpp_recipients) sppoo = subprocess.Popen(sendxmpp_cmd+sendxmpp_recipients,stdin=subprocess.PIPE,shell=True) - sppoo.communicate(input=sendxmpp_msg_closed+time.strftime(" (%Y-%m-%d %T)")) + sppoo.communicate(input=(sendxmpp_msg_closed % action_by)+time.strftime(" (%Y-%m-%d %T)")) sppoo.wait() logging.debug("XMPP Message about door closing sent") except Exception, e: @@ -86,6 +87,7 @@ if len(sys.argv) > 2: sendxmpp_recipients = " ".join(sys.argv[2:]) sockhandle=socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) re_status = re.compile(r'Status: (\w+), idle') +re_request = re.compile(r'Request: (\w+) (?:Card )?(.+)') while True: try: sockhandle.connect(socketfile) @@ -102,6 +104,12 @@ while True: display_open() if status == "closed": display_closed() + m = re_request.match(line) + if not m is None: + #(rq_action,rq_by) = m.group(1,2) + action_by=" von "+m.group(2) + else: + action_by="" except Exception, e: logging.error(str(e)) try: -- 1.7.10.4