from LATClient import LATClient
from select import select
+import signal
import sys
def check_door_service(service, test_string="got wombles?"):
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])
+ result_codes = { 'open' : 0, 'closed' : 1, 'error' : 2, 'invalid args' : 3}
+ def return_result(result):
+ print result
+ sys.exit(result_codes[result])
+ def timeout(signum, frame):
+ return_result("error")
+ if len(sys.argv) <> 2: return_result('invalid args')
+ signal.signal(signal.SIGALRM, timeout)
+ signal.alarm(15)
+ return_result(check_door_service(sys.argv[1]))