diff --git a/gns3server/utils/interfaces.py b/gns3server/utils/interfaces.py index e8597cc8..f0145341 100644 --- a/gns3server/utils/interfaces.py +++ b/gns3server/utils/interfaces.py @@ -20,7 +20,6 @@ import sys import aiohttp import socket import struct -import netifaces import logging log = logging.getLogger(__name__) @@ -115,10 +114,12 @@ def is_interface_up(interface): :returns: boolean """ - if interface not in netifaces.interfaces(): - return False - if sys.platform.startswith("linux"): + + import netifaces + if interface not in netifaces.interfaces(): + return False + import fcntl SIOCGIFFLAGS = 0x8913 try: @@ -144,6 +145,7 @@ def interfaces(): results = [] if not sys.platform.startswith("win"): + import netifaces for interface in netifaces.interfaces(): ip_address = "" ip_addresses = netifaces.ifaddresses(interface) diff --git a/setup.py b/setup.py index b0f8379b..a41e309b 100644 --- a/setup.py +++ b/setup.py @@ -45,12 +45,14 @@ dependencies = [ "raven>=5.2.0" ] -try: - import netifaces -except ImportError: - # add gns3-netifaces only if netifaces isn't already installed - # for instance via a Debian package. - dependencies.append("gns3-netifaces>=0.10.4.1") +if not sys.platform.startswith("win"): + # netifaces if not used on Windows + try: + import netifaces + except ImportError: + # add gns3-netifaces only if netifaces isn't already installed + # for instance via a Debian package. + dependencies.append("gns3-netifaces>=0.10.4.1") setup( name="gns3-server",