From: Grahame Bowland Date: Thu, 23 Dec 2004 11:01:21 +0000 (+0000) Subject: * add door client X-Git-Tag: IMPORT-FROM-UCCCVS~45 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=f777fb049153ec60c841b0dbbbeb24d57e8a2718;p=uccvend-vendserver.git * add door client --- diff --git a/sql-edition/servers/DoorClient.py b/sql-edition/servers/DoorClient.py new file mode 100755 index 0000000..56a4814 --- /dev/null +++ b/sql-edition/servers/DoorClient.py @@ -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])