mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
Fix RuntimeWarning: You have iterated over the result of
pkg_resources.parse_version. This is a legacy behavior Fix #504
This commit is contained in:
parent
978ec1b5be
commit
d952718f30
@ -24,7 +24,7 @@ import tempfile
|
|||||||
import psutil
|
import psutil
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
from pkg_resources import parse_version
|
from gns3server.utils import parse_version
|
||||||
from ..utils.asyncio import wait_run_in_executor
|
from ..utils.asyncio import wait_run_in_executor
|
||||||
from ..ubridge.hypervisor import Hypervisor
|
from ..ubridge.hypervisor import Hypervisor
|
||||||
from .vm_error import VMError
|
from .vm_error import VMError
|
||||||
|
@ -24,7 +24,7 @@ import logging
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import urllib
|
import urllib
|
||||||
import json
|
import json
|
||||||
from pkg_resources import parse_version
|
from gns3server.utils import parse_version
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
from gns3server.utils.interfaces import interfaces, is_interface_up
|
from gns3server.utils.interfaces import interfaces, is_interface_up
|
||||||
from gns3server.utils.asyncio import wait_run_in_executor
|
from gns3server.utils.asyncio import wait_run_in_executor
|
||||||
from pkg_resources import parse_version
|
from gns3server.utils import parse_version
|
||||||
from uuid import UUID, uuid4
|
from uuid import UUID, uuid4
|
||||||
from ..base_manager import BaseManager
|
from ..base_manager import BaseManager
|
||||||
from ..project_manager import ProjectManager
|
from ..project_manager import ProjectManager
|
||||||
|
@ -21,7 +21,7 @@ http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L558
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from pkg_resources import parse_version
|
from gns3server.utils import parse_version
|
||||||
|
|
||||||
from .device import Device
|
from .device import Device
|
||||||
from ..nios.nio_udp import NIOUDP
|
from ..nios.nio_udp import NIOUDP
|
||||||
|
@ -30,7 +30,7 @@ import asyncio
|
|||||||
import socket
|
import socket
|
||||||
import gns3server
|
import gns3server
|
||||||
|
|
||||||
from pkg_resources import parse_version
|
from gns3server.utils import parse_version
|
||||||
from .qemu_error import QemuError
|
from .qemu_error import QemuError
|
||||||
from ..adapters.ethernet_adapter import EthernetAdapter
|
from ..adapters.ethernet_adapter import EthernetAdapter
|
||||||
from ..nios.nio_udp import NIOUDP
|
from ..nios.nio_udp import NIOUDP
|
||||||
|
@ -28,7 +28,7 @@ import json
|
|||||||
import socket
|
import socket
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from pkg_resources import parse_version
|
from gns3server.utils import parse_version
|
||||||
from gns3server.utils.telnet_server import TelnetServer
|
from gns3server.utils.telnet_server import TelnetServer
|
||||||
from gns3server.utils.asyncio import wait_for_file_creation, wait_for_named_pipe_creation
|
from gns3server.utils.asyncio import wait_for_file_creation, wait_for_named_pipe_creation
|
||||||
from .virtualbox_error import VirtualBoxError
|
from .virtualbox_error import VirtualBoxError
|
||||||
|
@ -31,7 +31,7 @@ import codecs
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from gns3server.utils.interfaces import interfaces
|
from gns3server.utils.interfaces import interfaces
|
||||||
from gns3server.utils.asyncio import subprocess_check_output
|
from gns3server.utils.asyncio import subprocess_check_output
|
||||||
from pkg_resources import parse_version
|
from gns3server.utils import parse_version
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ import shutil
|
|||||||
from ...utils.asyncio import wait_for_process_termination
|
from ...utils.asyncio import wait_for_process_termination
|
||||||
from ...utils.asyncio import monitor_process
|
from ...utils.asyncio import monitor_process
|
||||||
from ...utils.asyncio import subprocess_check_output
|
from ...utils.asyncio import subprocess_check_output
|
||||||
from pkg_resources import parse_version
|
from gns3server.utils import parse_version
|
||||||
from .vpcs_error import VPCSError
|
from .vpcs_error import VPCSError
|
||||||
from ..adapters.ethernet_adapter import EthernetAdapter
|
from ..adapters.ethernet_adapter import EthernetAdapter
|
||||||
from ..nios.nio_udp import NIOUDP
|
from ..nios.nio_udp import NIOUDP
|
||||||
|
@ -25,7 +25,7 @@ import asyncio
|
|||||||
import socket
|
import socket
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from pkg_resources import parse_version
|
from gns3server.utils import parse_version
|
||||||
from gns3server.utils.asyncio import wait_for_process_termination
|
from gns3server.utils.asyncio import wait_for_process_termination
|
||||||
from gns3server.utils.asyncio import subprocess_check_output
|
from gns3server.utils.asyncio import subprocess_check_output
|
||||||
from .ubridge_hypervisor import UBridgeHypervisor
|
from .ubridge_hypervisor import UBridgeHypervisor
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
import re
|
||||||
import textwrap
|
import textwrap
|
||||||
import posixpath
|
import posixpath
|
||||||
|
|
||||||
@ -44,3 +45,32 @@ def int_to_macaddress(integer):
|
|||||||
Convert an integer to a macaddress
|
Convert an integer to a macaddress
|
||||||
"""
|
"""
|
||||||
return ":".join(textwrap.wrap("%012x" % (integer), width=2))
|
return ":".join(textwrap.wrap("%012x" % (integer), width=2))
|
||||||
|
|
||||||
|
|
||||||
|
def parse_version(version):
|
||||||
|
"""
|
||||||
|
Return a comparable tuple from a version string.
|
||||||
|
|
||||||
|
Replace pkg_resources.parse_version which now display a warning when use for comparing version with tuple
|
||||||
|
|
||||||
|
:returns: Version string as comparable tuple
|
||||||
|
"""
|
||||||
|
|
||||||
|
release_type_found = False
|
||||||
|
version_infos = re.split('(\.|[a-z]+)', version)
|
||||||
|
version = []
|
||||||
|
for info in version_infos:
|
||||||
|
if info == '.' or len(info) == 0:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
info = int(info)
|
||||||
|
version.append(info)
|
||||||
|
except ValueError:
|
||||||
|
# We want rc to be at lower level than dev version
|
||||||
|
if info == 'rc':
|
||||||
|
info = 'c'
|
||||||
|
version.append(info)
|
||||||
|
release_type_found = True
|
||||||
|
if release_type_found is False:
|
||||||
|
version.append("final")
|
||||||
|
return tuple(version)
|
||||||
|
@ -22,7 +22,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from tests.utils import asyncio_patch
|
from tests.utils import asyncio_patch
|
||||||
from pkg_resources import parse_version
|
from gns3server.utils import parse_version
|
||||||
from unittest.mock import patch, MagicMock
|
from unittest.mock import patch, MagicMock
|
||||||
|
|
||||||
from gns3server.modules.vpcs.vpcs_vm import VPCSVM
|
from gns3server.modules.vpcs.vpcs_vm import VPCSVM
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
from gns3server.utils import force_unix_path, macaddress_to_int, int_to_macaddress
|
from gns3server.utils import *
|
||||||
|
|
||||||
|
|
||||||
def test_force_unix_path():
|
def test_force_unix_path():
|
||||||
@ -31,3 +31,18 @@ def test_macaddress_to_int():
|
|||||||
|
|
||||||
def test_int_to_macaddress():
|
def test_int_to_macaddress():
|
||||||
assert int_to_macaddress(52228632586) == "00:0c:29:11:b0:0a"
|
assert int_to_macaddress(52228632586) == "00:0c:29:11:b0:0a"
|
||||||
|
|
||||||
|
|
||||||
|
def test_parse_version():
|
||||||
|
assert parse_version('1') == (1, 'final')
|
||||||
|
assert parse_version('1.3') == (1, 3, 'final')
|
||||||
|
assert parse_version('1.3.dev3') == (1, 3, 'dev', 3)
|
||||||
|
assert parse_version('1.3a1') == (1, 3, 'a', 1)
|
||||||
|
assert parse_version('1.3rc1') == (1, 3, 'c', 1)
|
||||||
|
|
||||||
|
assert parse_version('1.2.3') > parse_version('1.2.2')
|
||||||
|
assert parse_version('1.3') > parse_version('1.2.2')
|
||||||
|
assert parse_version('1.3') > parse_version('1.3alpha1')
|
||||||
|
assert parse_version('1.3') > parse_version('1.3rc1')
|
||||||
|
assert parse_version('1.3rc1') > parse_version('1.3alpha3')
|
||||||
|
assert parse_version('1.3dev1') > parse_version('1.3rc1')
|
||||||
|
Loading…
Reference in New Issue
Block a user