From 0d379f428e5c483e72a7a660920bee569550bd8c Mon Sep 17 00:00:00 2001 From: grossmj Date: Sat, 7 Mar 2015 18:16:46 -0700 Subject: [PATCH] Makes absolute path checks work on Windows. --- gns3server/modules/dynamips/nodes/router.py | 3 +-- gns3server/modules/iou/iou_vm.py | 2 +- gns3server/modules/qemu/qemu_vm.py | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gns3server/modules/dynamips/nodes/router.py b/gns3server/modules/dynamips/nodes/router.py index aff7683b..706fc319 100644 --- a/gns3server/modules/dynamips/nodes/router.py +++ b/gns3server/modules/dynamips/nodes/router.py @@ -421,8 +421,7 @@ class Router(BaseVM): :param image: path to IOS image file """ - if not os.path.dirname(image): - # this must be a relative path + if not os.path.isabs(image): server_config = Config.instance().get_section_config("Server") image = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), image) diff --git a/gns3server/modules/iou/iou_vm.py b/gns3server/modules/iou/iou_vm.py index f93ccc7d..ea90f446 100644 --- a/gns3server/modules/iou/iou_vm.py +++ b/gns3server/modules/iou/iou_vm.py @@ -131,7 +131,7 @@ class IOUVM(BaseVM): :params path: Path to the binary """ - if path[0] != "/": + if not os.path.isabs(path): server_config = Config.instance().get_section_config("Server") path = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), path) diff --git a/gns3server/modules/qemu/qemu_vm.py b/gns3server/modules/qemu/qemu_vm.py index 89ac9f45..a270e0f3 100644 --- a/gns3server/modules/qemu/qemu_vm.py +++ b/gns3server/modules/qemu/qemu_vm.py @@ -183,7 +183,7 @@ class QemuVM(BaseVM): :param hda_disk_image: QEMU hda disk image path """ - if hda_disk_image[0] != "/": + if os.path.isabs(hda_disk_image): server_config = Config.instance().get_section_config("Server") hda_disk_image = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), hda_disk_image) @@ -210,7 +210,7 @@ class QemuVM(BaseVM): :param hdb_disk_image: QEMU hdb disk image path """ - if hdb_disk_image[0] != "/": + if not os.path.isabs(hdb_disk_image): server_config = Config.instance().get_section_config("Server") hdb_disk_image = os.path.join(os.path.expanduser(server_config.get("images_path", "~/GNS3/images")), hdb_disk_image)