mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 03:08:14 +00:00
Change seperator for additonnal images directory otherwise bug on windows
This commit is contained in:
parent
2c73d40551
commit
20772a310b
@ -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):
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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():
|
||||
|
@ -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)]
|
||||
|
Loading…
Reference in New Issue
Block a user