def handler(signal, frame): log.printv() log << "Received signal " + ` signal ` + "." log << "Closing connection ..." client.closeConnection() if client.isClosed == True: log << "Client connection closed." process.remove_pid_file()
def handler(signal, frame): log.printv() log << "Received signal " + `signal` + "." log << "Closing connection ..." client.closeConnection() if client.isClosed == True: log << "Client connection closed." process.remove_pid_file() log << "Exit." sys.exit(0)
log.warning(error) client.send(abo, ":ERROR %s\n" % error) else: if on: log << "Beam on." else: log << "Beam off." elif len(commands) == 1 and commands[0].upper() == "FINISHED": client.send(abo, ":FINISHED\n") elif len(commands) == 1 and commands[0].upper() == "EXIT": break else: if not check_state(xray_generator, state_kV, state_mA, state_HV): log.warning("Error: Xray generator state changed unexpectedly!") client.send(abo, ":ERROR Xray generator state changed unexpectedly!\n") # Get the new state to avoid sending more errors state_kV = xray_generator.get_voltage() state_mA = xray_generator.get_current() state_HV = xray_generator.get_hv() time.sleep(0.5) log.printv() log << "Closing connection ..." client.closeConnection() if client.isClosed == True: log << "Client connection closed." log << "Exit." process.remove_pid_file()
log << "Power cycling ..." device.power_cycle() # Sleep afterwards, to let the electronics start up time.sleep(2) state_output = device.get_output() if commands[1].upper() == "TOGGLE": log << "Toggling output ..." device.toggle_output() state_output = device.get_output() elif len(commands) == 1 and commands[0].upper() == "FINISHED": log << "Acknowledged." client.send(abo, ":FINISHED\n") elif len(commands) == 1 and commands[0].upper() == "EXIT": break else: if not check_state(device, state_output): log.warning("Error: low voltage device state changed unexpectedly!") client.send(abo, ":ERROR low voltage device state changed unexpectedly!\n") # Get the new state to avoid sending more errors state_output = device.get_state() time.sleep(0.5) log.printv() log << "Closing connection ..." client.closeConnection() if client.isClosed == True: log << "Client connection closed." log << "Exit." process.remove_pid_file()