diff --git a/gns3server/modules/iou/__init__.py b/gns3server/modules/iou/__init__.py index 5ae65f98..e7d2c0c6 100644 --- a/gns3server/modules/iou/__init__.py +++ b/gns3server/modules/iou/__init__.py @@ -69,18 +69,15 @@ class IOU(IModule): iou_config = config.get_section_config(name.upper()) self._iouyap = iou_config.get("iouyap") if not self._iouyap or not os.path.isfile(self._iouyap): - iouyap_in_cwd = os.path.join(os.getcwd(), "iouyap") - if os.path.isfile(iouyap_in_cwd): - self._iouyap = iouyap_in_cwd - else: - # look for iouyap if none is defined or accessible - for path in os.environ["PATH"].split(":"): - try: - if "iouyap" in os.listdir(path) and os.access(os.path.join(path, "iouyap"), os.X_OK): - self._iouyap = os.path.join(path, "iouyap") - break - except OSError: - continue + paths = [os.getcwd()] + os.environ["PATH"].split(":") + # look for iouyap in the current working directory and $PATH + for path in paths: + try: + if "iouyap" in os.listdir(path) and os.access(os.path.join(path, "iouyap"), os.X_OK): + self._iouyap = os.path.join(path, "iouyap") + break + except OSError: + continue if not self._iouyap: log.warning("iouyap binary couldn't be found!") diff --git a/gns3server/modules/vpcs/__init__.py b/gns3server/modules/vpcs/__init__.py index 3ef9347c..5c31310a 100644 --- a/gns3server/modules/vpcs/__init__.py +++ b/gns3server/modules/vpcs/__init__.py @@ -66,18 +66,15 @@ class VPCS(IModule): vpcs_config = config.get_section_config(name.upper()) self._vpcs = vpcs_config.get("vpcs") if not self._vpcs or not os.path.isfile(self._vpcs): - vpcs_in_cwd = os.path.join(os.getcwd(), "vpcs") - if os.path.isfile(vpcs_in_cwd): - self._vpcs = vpcs_in_cwd - else: - # look for vpcs if none is defined or accessible - for path in os.environ["PATH"].split(":"): - try: - if "vpcs" in os.listdir(path) and os.access(os.path.join(path, "vpcs"), os.X_OK): - self._vpcs = os.path.join(path, "vpcs") - break - except OSError: - continue + paths = [os.getcwd()] + os.environ["PATH"].split(":") + # look for VPCS in the current working directory and $PATH + for path in paths: + try: + if "vpcs" in os.listdir(path) and os.access(os.path.join(path, "vpcs"), os.X_OK): + self._vpcs = os.path.join(path, "vpcs") + break + except OSError: + continue if not self._vpcs: log.warning("VPCS binary couldn't be found!") @@ -241,6 +238,9 @@ class VPCS(IModule): except OSError as e: raise VPCSError("Could not create working directory {}".format(e)) + if not self._vpcs: + raise VPCSError("No path to a VPCS executable has been set") + vpcs_instance = VPCSDevice(self._vpcs, self._working_dir, self._host, diff --git a/gns3server/modules/vpcs/vpcs_device.py b/gns3server/modules/vpcs/vpcs_device.py index 5e3263bb..23bd6970 100644 --- a/gns3server/modules/vpcs/vpcs_device.py +++ b/gns3server/modules/vpcs/vpcs_device.py @@ -321,6 +321,9 @@ class VPCSDevice(object): if not self.is_running(): + if not self._path: + raise VPCSError("No path to a VPCS executable has been set") + if not os.path.isfile(self._path): raise VPCSError("VPCS '{}' is not accessible".format(self._path))