mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-26 15:30:18 +00:00
Added conditional import of netifaces
This commit is contained in:
parent
f5236878b0
commit
10854bfdbc
@ -286,7 +286,7 @@ class TCPServerInterface(Interface):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_address_for_if(name):
|
def get_address_for_if(name):
|
||||||
import importlib
|
import importlib
|
||||||
if importlib.find_loader('netifaces') != None:
|
if importlib.util.find_spec('netifaces') != None:
|
||||||
import netifaces
|
import netifaces
|
||||||
return netifaces.ifaddresses(name)[netifaces.AF_INET][0]['addr']
|
return netifaces.ifaddresses(name)[netifaces.AF_INET][0]['addr']
|
||||||
else:
|
else:
|
||||||
@ -297,7 +297,7 @@ class TCPServerInterface(Interface):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_broadcast_for_if(name):
|
def get_broadcast_for_if(name):
|
||||||
import importlib
|
import importlib
|
||||||
if importlib.find_loader('netifaces') != None:
|
if importlib.util.find_spec('netifaces') != None:
|
||||||
import netifaces
|
import netifaces
|
||||||
return netifaces.ifaddresses(name)[netifaces.AF_INET][0]['broadcast']
|
return netifaces.ifaddresses(name)[netifaces.AF_INET][0]['broadcast']
|
||||||
else:
|
else:
|
||||||
|
@ -12,7 +12,7 @@ class UDPInterface(Interface):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_address_for_if(name):
|
def get_address_for_if(name):
|
||||||
import importlib
|
import importlib
|
||||||
if importlib.find_loader('netifaces') != None:
|
if importlib.util.find_spec('netifaces') != None:
|
||||||
import netifaces
|
import netifaces
|
||||||
return netifaces.ifaddresses(name)[netifaces.AF_INET][0]['addr']
|
return netifaces.ifaddresses(name)[netifaces.AF_INET][0]['addr']
|
||||||
else:
|
else:
|
||||||
@ -23,7 +23,7 @@ class UDPInterface(Interface):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_broadcast_for_if(name):
|
def get_broadcast_for_if(name):
|
||||||
import importlib
|
import importlib
|
||||||
if importlib.find_loader('netifaces') != None:
|
if importlib.util.find_spec('netifaces') != None:
|
||||||
import netifaces
|
import netifaces
|
||||||
return netifaces.ifaddresses(name)[netifaces.AF_INET][0]['broadcast']
|
return netifaces.ifaddresses(name)[netifaces.AF_INET][0]['broadcast']
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user