More specific path checks (file vs directory).

This commit is contained in:
grossmj committed 2014-04-11 14:48:30 -06:00
1 parent 8020c2e99c
commit 96231e3f7f
8 files changed
+16 -16

No files matched your search

+3 -3
View File
@@ -198,14 +198,14 @@ class Dynamips(IModule):
"""
# check if Dynamips path exists
if not os.path.exists(self._dynamips):
if not os.path.isfile(self._dynamips):
raise DynamipsError("Dynamips executable {} doesn't exist".format(self._dynamips))
# check if Dynamips is executable
if not os.access(self._dynamips, os.X_OK):
raise DynamipsError("Dynamips {} is not executable".format(self._dynamips))
if not os.path.exists(self._working_dir):
if not os.path.isdir(self._working_dir):
try:
os.makedirs(self._working_dir)
except OSError as e:
@@ -407,7 +407,7 @@ class Dynamips(IModule):
config = "!\n" + config.replace("\r", "")
config = config.replace('%h', router.name)
config_dir = os.path.join(router.hypervisor.working_dir, "configs")
if not os.path.exists(config_dir):
if not os.path.isdir(config_dir):
try:
os.makedirs(config_dir)
except OSError as e:
@@ -455,7 +455,7 @@ class HypervisorManager(object):
port = self.allocate_tcp_port()
# working_dir = os.path.join(self._working_dir, "instance-{}".format(port))
# if not os.path.exists(working_dir):
# if not os.path.isdir(working_dir):
# try:
# os.makedirs(working_dir)
# except OSError as e: