def getAinPinName(pin): hits = glob("/sys/bus/iio/devices/iio:device?/in_voltage%s_raw" % pin) if hits: return hits[0] else: log.fatal("Could not find ADC pin %s, double check that the firmware loaded..." % pin) from pwm_utilities import stopEverythingAndQuit stopEverythingAndQuit()
def safeRun(main): setupSignalHandlers() try: main() except Exception: # no matter what everything should stop, so catch everything err = traceback.format_exc() log.error("Something's gone horribly wrong! %s" % err) from pwm_utilities import stopEverythingAndQuit stopEverythingAndQuit()
def getAinPinName(pin): hits = glob("/sys/bus/iio/devices/iio:device?/in_voltage%s_raw" % pin) if hits: return hits[0] else: log.fatal( "Could not find ADC pin %s, double check that the firmware loaded..." % pin) from pwm_utilities import stopEverythingAndQuit stopEverythingAndQuit()
def setupSignalHandlers(): import signal from pwm_utilities import stopEverythingAndQuit signal.signal(signal.SIGABRT, lambda a,b: stopEverythingAndQuit()) signal.signal(signal.SIGINT, lambda a,b: stopEverythingAndQuit()) signal.signal(signal.SIGQUIT, lambda a,b: stopEverythingAndQuit())