def shutdown(self, signum=None, frame=None): if self.shutdownInProgress(): return self.shutdown_triggered = True if signum: self.logger.critical('Shutdown triggered with signal %d' % signum) shutdown_called_directly = False else: self.logger.critical('Shutdown called directly') shutdown_called_directly = True self.stopThreads(shutdown_called_directly) self.removePIDFile() linux_hub.set_led_state('zigbee', 'off') linux_hub.set_led_state('bergcloud', 'off') linux_hub.hold_reset_ncp() self.logger.critical('Shutdown complete!') sys.stderr = sys.__stderr__ sys.stdout = sys.__stdout__ sys.stdout.flush() sys.stderr.flush() if not self.options.daemon: self.logger.critical( 'Shutdown complete. Please exit the interactive prompt if you have one open' ) elif self.should_reboot == True: self.logger.critical('Farewell! (99)') sys.exit(99) if signum == 14: self.logger.critical('Goodbye! (1)') sys.exit(1) else: self.logger.critical('See you soon! (0)') sys.exit(0)
def shutdown(self, signum = None, frame = None): if self.shutdownInProgress(): return self.shutdown_triggered = True if signum: self.logger.critical('Shutdown triggered with signal %d' % signum) shutdown_called_directly = False else: self.logger.critical('Shutdown called directly') shutdown_called_directly = True self.stopThreads(shutdown_called_directly) self.removePIDFile() linux_hub.set_led_state('zigbee', 'off') linux_hub.set_led_state('bergcloud', 'off') linux_hub.hold_reset_ncp() self.logger.critical('Shutdown complete!') sys.stderr = sys.__stderr__ sys.stdout = sys.__stdout__ sys.stdout.flush() sys.stderr.flush() if not self.options.daemon: self.logger.critical('Shutdown complete. Please exit the interactive prompt if you have one open') elif self.should_reboot == True: self.logger.critical('Farewell! (99)') sys.exit(99) if signum == 14: self.logger.critical('Goodbye! (1)') sys.exit(1) else: self.logger.critical('See you soon! (0)') sys.exit(0)
def opened(self): self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 3) self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 3) self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 5) self.connectionState = 'connected' linux_hub.set_led_state('bergcloud', 'on', True) self.logger.info('Websocket open and connected')
def checkConnectedDevices(self): while not self.zigbee_led_thread_exit_event.isSet(): if self.watchdog_delegate: self.watchdog_delegate.updateKey('ledThread') if self.networkUp() == False: linux_hub.set_led_state('zigbee', 'off', True) self.zigbee_led_thread_exit_event.wait(1) elif self.event_queue.full(): linux_hub.zigbee_event_queue_full_sequence(self.zigbee_led_thread_exit_event) self.zigbee_led_thread_exit_event.wait(1) elif len(self.berg_cloud_api.event_sources.keys()) == 0: linux_hub.zigbee_searching_sequence(self.zigbee_led_thread_exit_event) else: linux_hub.set_led_state('zigbee', 'on', True) self.zigbee_led_thread_exit_event.wait(1)
def closed(self, code, reason = None): self.connectionState = 'closed' linux_hub.set_led_state('bergcloud', 'off', True) self.logger.warning('Closed down websocket, code: %d, reason: %s' % (code, reason))
device.shutdown() zigbee_functional = True print 'Zigbee functional' except: print 'Zigbee non-functional' try: ip = get_ip_address('eth0') print 'Ethernet/IP functional' tcpip_functional = True except: print 'Ethernet/IP non-functional' flip_flop = 'off' while True: if flip_flop == 'on': flip_flop = 'off' else: flip_flop = 'on' if zigbee_functional: linux_hub.set_led_state('zigbee', flip_flop) if tcpip_functional: linux_hub.set_led_state('ethernet', flip_flop) linux_hub.set_led_state('bergcloud', flip_flop) time.sleep(0.01) print 'Finished engineering test procedure' sys.exit(0) +++ okay decompyling ./engtest.pyc # decompiled 1 files: 1 okay, 0 failed, 0 verify failed # 2016.01.27 00:42:39 MSK