3 from LATClient import LATClient
4 from select import select
7 def check_door_service(service, test_string="got wombles?"):
8 latclient = LATClient(service=sys.argv[1])
9 latclient.sock.send(test_string)
10 rfh, wfh = latclient.get_fh()
11 wfh.write(test_string)
13 rr, wr, er = select([rfh], [], [], 10.0)
14 if rfh not in rr: return "open"
15 recv = rfh.read(len(test_string))
16 if recv <> test_string: return "error"
19 if __name__ == '__main__':
20 result_codes = { 'open' : 0, 'closed' : 1, 'error' : 2 }
21 result = check_door_service(sys.argv[1])
23 sys.exit(result_codes[result])