1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-29 02:08:10 +00:00

Change seperator for additonnal images directory otherwise bug on windows

This commit is contained in:
Julien Duponchelle 2016-09-27 17:15:59 +02:00
parent 2c73d40551
commit 20772a310b
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
5 changed files with 9 additions and 9 deletions

View File

@ -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):

View File

@ -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)

View File

@ -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

View File

@ -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():

View File

@ -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)]