* add door client
authorGrahame Bowland <grahame@ucc.gu.uwa.edu.au>
Thu, 23 Dec 2004 11:01:21 +0000 (11:01 +0000)
committerGrahame Bowland <grahame@ucc.gu.uwa.edu.au>
Thu, 23 Dec 2004 11:01:21 +0000 (11:01 +0000)
sql-edition/servers/DoorClient.py [new file with mode: 0755]

diff --git a/sql-edition/servers/DoorClient.py b/sql-edition/servers/DoorClient.py
new file mode 100755 (executable)
index 0000000..56a4814
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/python
+
+from LATClient import LATClient
+from select import select
+import sys
+
+def check_door_service(service, test_string="got wombles?"):
+       latclient = LATClient(service=sys.argv[1])
+       latclient.sock.send(test_string)
+       rfh, wfh = latclient.get_fh()
+       wfh.write(test_string)
+       wfh.flush()
+       rr, wr, er = select([rfh], [], [], 10.0)
+       if rfh not in rr: return "open"
+       recv = rfh.read(len(test_string))
+       if recv <> test_string: return "error"
+       return "closed"
+
+if __name__ == '__main__':
+       result_codes = { 'open' : 0, 'closed' : 1, 'error' : 2 }
+       result = check_door_service(sys.argv[1])
+       print result
+       sys.exit(result_codes[result])

UCC git Repository :: git.ucc.asn.au