diff --git a/gns3server/utils/__init__.py b/gns3server/utils/__init__.py index e8e0a297..abefda8d 100644 --- a/gns3server/utils/__init__.py +++ b/gns3server/utils/__init__.py @@ -19,15 +19,16 @@ import re import os import textwrap -import pathlib +import posixpath + def force_unix_path(path): """ :param path: Path to convert """ - p = pathlib.Path(os.path.normpath(path)) - return p.as_posix() + path = path.replace("\\", "/") + return posixpath.normpath(path) def macaddress_to_int(mac_address): diff --git a/gns3server/utils/images.py b/gns3server/utils/images.py index 455f21e0..a838a1d1 100644 --- a/gns3server/utils/images.py +++ b/gns3server/utils/images.py @@ -71,7 +71,7 @@ def images_directories(type): raise NotImplementedError("%s is not supported", type) os.makedirs(type_img_directory, exist_ok=True) paths.append(type_img_directory) - for directory in server_config.get("additional_images_path", "").split(":"): + for directory in server_config.get("additional_images_path", "").split(";"): paths.append(directory) # Compatibility with old topologies we look in parent directory paths.append(img_dir) diff --git a/tests/compute/test_manager.py b/tests/compute/test_manager.py index eb88aa7e..647d63ce 100644 --- a/tests/compute/test_manager.py +++ b/tests/compute/test_manager.py @@ -136,7 +136,7 @@ def test_get_abs_image_additional_image_paths(qemu, tmpdir): with patch("gns3server.config.Config.get_section_config", return_value={ "images_path": str(tmpdir / "images1"), - "additional_images_path": "/tmp/null24564:{}".format(str(tmpdir / "images2")), + "additional_images_path": "/tmp/null24564;{}".format(str(tmpdir / "images2")), "local": False}): assert qemu.get_abs_image_path("test1.bin") == path1 assert qemu.get_abs_image_path("test2.bin") == path2 diff --git a/tests/test_utils.py b/tests/test_utils.py index c188c044..af7d9815 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -23,8 +23,7 @@ def test_force_unix_path(): assert force_unix_path("a/b") == "a/b" assert force_unix_path("a\\b") == "a/b" assert force_unix_path("a\\b\\..\\c") == "a/c" - if sys.platform.startswith("win"): - assert force_unix_path("C:\Temp") == "C:/Temp" + assert force_unix_path("C:\Temp") == "C:/Temp" def test_macaddress_to_int(): diff --git a/tests/utils/test_images.py b/tests/utils/test_images.py index 48c2fb6f..5fb0fad2 100644 --- a/tests/utils/test_images.py +++ b/tests/utils/test_images.py @@ -34,7 +34,7 @@ def test_images_directories(tmpdir): with patch("gns3server.config.Config.get_section_config", return_value={ "images_path": str(tmpdir / "images1"), - "additional_images_path": "/tmp/null24564:{}".format(tmpdir / "images2"), + "additional_images_path": "/tmp/null24564;{}".format(tmpdir / "images2"), "local": False}): # /tmp/null24564 is ignored because doesn't exists @@ -115,7 +115,7 @@ def test_scan_for_images(tmpdir): with patch("gns3server.config.Config.get_section_config", return_value={ "images_path": str(tmpdir / "images1"), - "additional_images_path": "/tmp/null24564:{}".format(tmpdir / "images2"), + "additional_images_path": "/tmp/null24564;{}".format(tmpdir / "images2"), "local": False}): assert scan_for_images("dynamips") == [str(path1), str(path2)]