def run(self): self._stopped = False self._loop = GObject.MainLoop() self._propertiesListener = NetworkManager.NetworkManager.OnPropertiesChanged(self.propertiesChanged) self._stateChangeListener = NetworkManager.NetworkManager.OnStateChanged(self.globalStateChanged) connectionState = NetworkManager.NetworkManager.State logger.info('Network Manager reports state: *[%s]*' % NetworkManager.const('state', connectionState)) if connectionState == NetworkManager.NM_STATE_CONNECTED_GLOBAL: self._setOnline(True) #d = self.getActiveConnectionDevice() #if d: # self._devicePropertiesListener = d.Dhcp4Config.connect_to_signal('PropertiesChanged', self.activeDeviceConfigChanged) # self._currentIpv4Address = d.Ip4Address # self._activeDevice = d # self._online = True # logger.info('Active Connection found at %s (%s)' % (d.IpInterface, d.Ip4Address)) while not self._stopped: try: self._loop.run() except KeyboardInterrupt: #kill the main process too from octoprint import astrobox astrobox.stop() except DBusException as e: #GObject.idle_add(logger.error, 'Exception during NetworkManagerEvents: %s' % e) logger.error('Exception during NetworkManagerEvents: %s' % e) finally: self.stop()