def __init__(self, args):
        self.args = args

        # Stop any running GPIOnext1 components
        subprocess.call(('systemctl', 'stop', 'gpionext1'))
        time.sleep(1)  #give time to stop processes
        try:
            active = subprocess.check_output(
                ['systemctl', 'is-active', 'gpionext1'])
        except:
            active = 'active'
        if 'active' in active:
            self.DEBUG('ERROR: systemctl stop gpionext1 has failed!')
            self.DEBUG('Please stop gpionext1 before running config!')
        else:
            self.DEBUG('gpionext1 service has been successfully stopped')

        self.DEBUG('Initializing SIGNAL HANDLERS')
        for sig in [signal.SIGTERM, signal.SIGQUIT, signal.SIGINT]:
            signal.signal(sig, self.signal_handler)

        gpio.pinPressMethods.append(self.setTimer)
        gpio.pinReleaseMethods.append(self.clearTimer)

        self.set_args()
        SQL.init()
        gpio.setupGPIO(self.args)
        self.getControllerType()
Exemplo n.º 2
0
 def reload(self, signal, frame):
     self.DEBUG(addSeparator=True)
     self.DEBUG("Received Reload Signal. Reloading GPIOnext1!")
     self.DEBUG(addSeparator=True)
     gpio.cleanup()
     importlib.reload(gpio)
     importlib.reload(SQL)
     gpio.setupGPIO(self.args)
     SQL.init()
     self.devices = SQL.getDevices(DEVICE_LIST, self.args)
     gpio.registerDevices(self.devices)
Exemplo n.º 3
0
    def __init__(self, args):
        # Watch for system signals
        for sig in [signal.SIGTERM, signal.SIGQUIT, signal.SIGINT]:
            signal.signal(sig, self.signal_handler)
        signal.signal(signal.SIGHUP, self.reload)

        self.args = args
        self.set_args()
        gpio.setupGPIO(self.args)
        SQL.init()
        self.devices = SQL.getDevices(DEVICE_LIST, self.args)
        gpio.registerDevices(self.devices)
        self.main()