1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 09:18:08 +00:00

Netifaces is not used on Windows. Fixes #257.

This commit is contained in:
Jeremy 2015-07-08 14:51:21 -06:00
parent 37f4ff2f63
commit 870029123c
2 changed files with 14 additions and 10 deletions

View File

@ -20,7 +20,6 @@ import sys
import aiohttp import aiohttp
import socket import socket
import struct import struct
import netifaces
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -115,10 +114,12 @@ def is_interface_up(interface):
:returns: boolean :returns: boolean
""" """
if sys.platform.startswith("linux"):
import netifaces
if interface not in netifaces.interfaces(): if interface not in netifaces.interfaces():
return False return False
if sys.platform.startswith("linux"):
import fcntl import fcntl
SIOCGIFFLAGS = 0x8913 SIOCGIFFLAGS = 0x8913
try: try:
@ -144,6 +145,7 @@ def interfaces():
results = [] results = []
if not sys.platform.startswith("win"): if not sys.platform.startswith("win"):
import netifaces
for interface in netifaces.interfaces(): for interface in netifaces.interfaces():
ip_address = "" ip_address = ""
ip_addresses = netifaces.ifaddresses(interface) ip_addresses = netifaces.ifaddresses(interface)

View File

@ -45,6 +45,8 @@ dependencies = [
"raven>=5.2.0" "raven>=5.2.0"
] ]
if not sys.platform.startswith("win"):
# netifaces if not used on Windows
try: try:
import netifaces import netifaces
except ImportError: except ImportError: