def doCheckNetworkInterfaces(self, arg): # lg.out(4, 'network_connector.doCheckNetworkInterfaces') # TODO # self.automat('got-network-info', []) start_time = time.time() if bpio.Linux(): def _call(): return net_misc.getNetworkInterfaces() def _done(result, start_time): if _Debug: lg.out( _DebugLevel, 'network_connector.doCheckNetworkInterfaces DONE: %s in %d seconds' % (str(result), time.time() - start_time)) self.automat('got-network-info', result) d = threads.deferToThread(_call) d.addBoth(_done, start_time) else: ips = net_misc.getNetworkInterfaces() if _Debug: lg.out( _DebugLevel, 'network_connector.doCheckNetworkInterfaces DONE: %s in %d seconds' % (str(ips), time.time() - start_time)) self.automat('got-network-info', ips)
def _do_check_network_interfaces(self): from lib.net_misc import getNetworkInterfaces from p2p import network_connector from logs import lg known_interfaces = getNetworkInterfaces() if '127.0.0.1' in known_interfaces: known_interfaces.remove('127.0.0.1') if self.current_network_interfaces is None: self.current_network_interfaces = known_interfaces lg.info('current network interfaces on START UP: %r' % self.current_network_interfaces) else: if self.current_network_interfaces != known_interfaces and known_interfaces: lg.info( 'need to reconnect, recognized changes in network interfaces: %r -> %r' % (self.current_network_interfaces, known_interfaces)) self.current_network_interfaces = known_interfaces network_connector.A('reconnect')
def _do_check_network_interfaces(self): from lib.net_misc import getNetworkInterfaces from p2p import network_connector from logs import lg known_interfaces = getNetworkInterfaces() if '127.0.0.1' in known_interfaces: known_interfaces.remove('127.0.0.1') if self.current_network_interfaces is None: self.current_network_interfaces = known_interfaces lg.out( 2, 'service_network._do_check_network_interfaces START UP: %s' % self.current_network_interfaces) else: if self.current_network_interfaces != known_interfaces: lg.out( 2, 'service_network._do_check_network_interfaces recognized changes: %s -> %s' % (self.current_network_interfaces, known_interfaces)) self.current_network_interfaces = known_interfaces network_connector.A('check-reconnect')
def doCheckNetworkInterfaces(self, *args, **kwargs): start_time = time.time() # if bpio.Linux(): # def _call(): # return net_misc.getNetworkInterfaces() # # def _done(result, start_time): # if _Debug: # lg.out(_DebugLevel, 'network_connector.doCheckNetworkInterfaces DONE: %s in %d seconds' % (str(result), time.time() - start_time)) # if not result: # lg.err('no network interfaces found') # self.automat('got-network-info', result) # d = threads.deferToThread(_call) # d.addBoth(_done, start_time) # else: ips = net_misc.getNetworkInterfaces() if _Debug: lg.args(_DebugLevel, result=ips, tm=(time.time() - start_time)) if not ips: lg.err('no network interfaces found') self.automat('got-network-info', ips)
def _call(): return net_misc.getNetworkInterfaces()