From: James Andrewartha Date: Mon, 19 Oct 2009 14:54:41 +0000 (+0800) Subject: add some logging X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=d8d926c74fd4f05421f809445119bfcbe035c678;p=uccdoor.git add some logging --- diff --git a/server.py b/server.py index 64752f5..a816bf7 100755 --- a/server.py +++ b/server.py @@ -7,6 +7,7 @@ # statuses: 1 means open circuit, 0 means closed circuit, -1 means error +import syslog import dbus, dbus.service import gobject from LATClient import LATClient @@ -18,29 +19,38 @@ def check_LAT_service(servicename, retries=3): rfh, wfh = latclient.get_fh() results = {'error': retries, 'closed': retries, 'open': retries} test_string = "got wombles?" + syslog.syslog(30, "start check_LAT_service:" + servicename) # Only return after n(retries) consistent results, although not necessarily # in order. This means we poll at least (retries) and up to (retries ** 2) times. # This is mtearle's original code. No idea if it's the Right Thing. while True: + syslog.syslog(30, "running c_L_s loop:" + servicename) try: wfh.write(test_string) wfh.flush() except: results['error'] -= 1 if results['error'] == 0: return -1 + syslog.syslog(30, "c_L_s write error:" + servicename) continue + syslog.syslog(30, "c_Ls written data to " + servicename) rr, wr, er = select([rfh], [], [], 3.0) if rfh not in rr: results['open'] -= 1 if results['open'] == 0: return 1 + syslog.syslog(30, "c_L_s open: " + servicename) continue + syslog.syslog(30, "c_L_s select() succeeded: " + servicename) recv = rfh.read(len(test_string)) + syslog.syslog(30, "c_L_s read() succeeded: " + servicename) if recv <> test_string: + syslog.syslog(30, "c_L_s not the data we sent " + servicename) results['error'] -= 1 if results['error'] == 0: return -1 continue results['closed'] -= 1 + syslog.syslog(30, "c_L_s closed " + servicename) if results['closed'] == 0: return 0 class Door(dbus.service.Object):