From: Bernhard Tittelbach Date: Fri, 5 Mar 2010 04:17:05 +0000 (+0000) Subject: UpdateWebStatus uses Presence Tracker (!!! arguments and config file changed) X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=f7e232e0522447ef5719323b9a812fd2424cba8d;p=svn42.git UpdateWebStatus uses Presence Tracker (!!! arguments and config file changed) --- diff --git a/track-presence.py b/track-presence.py index a6d5694..0f449ad 100644 --- a/track-presence.py +++ b/track-presence.py @@ -319,9 +319,9 @@ class ConnectionListener: def statusString(self,somebody_present): if somebody_present: - return "people present" + "\n" + return "Status: people present" + "\n" else: - return "room empty" + "\n" + return "Status: room empty" + "\n" def updateStatus(self,somebody_present): presence_status_data = self.statusString(somebody_present) diff --git a/update-web-status.py b/update-web-status.py index 1de42ad..ef2535e 100755 --- a/update-web-status.py +++ b/update-web-status.py @@ -29,8 +29,10 @@ class UWSConfig: self.config_parser=ConfigParser.ConfigParser() self.config_parser.add_section('web') 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','htmlopen','
Tür ist Offen
') + #~ self.config_parser.set('web','htmlclosed','
Tür ist Geschlossen
') + self.config_parser.set('web','htmlopen','
Leute Anwesend
') + self.config_parser.set('web','htmlclosed','
Keiner Da
') self.config_parser.add_section('debug') self.config_parser.set('debug','enabled',"False") self.config_parser.add_section('tracker') @@ -184,30 +186,23 @@ signal.signal(signal.SIGQUIT, exitHandler) logging.info("Door Status Listener started") if len(sys.argv) > 1: - socketfile = sys.argv[1] -else: - socketfile = "/var/run/tuer/door_cmd.socket" - -if len(sys.argv) > 2: - uwscfg = UWSConfig(sys.argv[2]) + uwscfg = UWSConfig(sys.argv[1]) else: uwscfg = UWSConfig() #socket.setdefaulttimeout(10.0) #affects all new Socket Connections (urllib as well) -RE_STATUS = re.compile(r'Status: (\w+), idle') -RE_REQUEST = re.compile(r'Request: (\w+) (?:Card )?(.+)') -RE_ERROR = re.compile(r'Error: (.+)') +RE_STATUS = re.compile(r'Status: (people present|room empty)') while True: try: - if not os.path.exists(socketfile): - logging.debug("Socketfile '%s' not found, waiting 5 secs" % socketfile) + if not os.path.exists(uwscfg.tracker_socket): + logging.debug("Socketfile '%s' not found, waiting 5 secs" % uwscfg.tracker_socket) time.sleep(5) continue sockhandle = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - sockhandle.connect(socketfile) + sockhandle.connect(uwscfg.tracker_socket) conn = os.fdopen(sockhandle.fileno()) - sockhandle.send("listen\n") - sockhandle.send("status\n") + #sockhandle.send("listen\n") + #sockhandle.send("status\n") while True: line = conn.readline() logging.debug("Got Line: " + line) @@ -220,20 +215,10 @@ while True: m = RE_STATUS.match(line) if not m is None: status = m.group(1) - if status == "opened": + if status == "people present": displayOpen() - if status == "closed": + if status == "room empty": displayClosed() - #~ 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 = "" - #~ m = RE_ERROR.match(line) - #~ if not m is None: - #~ errorstr = m.group(1) - #~ #handle Error except Exception, ex: logging.error("main: "+str(ex)) try: