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

+4 -4
View File
@@ -54,9 +54,9 @@ class IOU(IModule):
config = Config.instance()
iou_config = config.get_section_config(name.upper())
self._iouyap = iou_config.get("iouyap")
if not self._iouyap or not os.path.exists(self._iouyap):
if not self._iouyap or not os.path.isfile(self._iouyap):
iouyap_in_cwd = os.path.join(os.getcwd(), "iouyap")
if os.path.exists(iouyap_in_cwd):
if os.path.isfile(iouyap_in_cwd):
self._iouyap = iouyap_in_cwd
else:
# look for iouyap if none is defined or accessible
@@ -153,7 +153,7 @@ class IOU(IModule):
self._current_console_port = self._console_start_port_range
self._current_udp_port = self._udp_start_port_range
if self._iourc and os.path.exists(self._iourc):
if self._iourc and os.path.isfile(self._iourc):
try:
log.info("deleting iourc file {}".format(self._iourc))
os.remove(self._iourc)
@@ -246,7 +246,7 @@ class IOU(IModule):
iou_path = request["path"]
try:
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:
+4 -4
View File
@@ -246,7 +246,7 @@ class IOUDevice(object):
# create our own working directory
working_dir = os.path.join(working_dir, "device-{}".format(self._id))
if not os.path.exists(working_dir):
if not os.path.isdir(working_dir):
try:
os.makedirs(working_dir)
except OSError as e:
@@ -413,13 +413,13 @@ class IOUDevice(object):
if not self.is_running():
if not os.path.exists(self._path):
if not os.path.isfile(self._path):
raise IOUError("IOU '{}' is not accessible".format(self._path))
if not self._iourc or not os.path.exists(self._iourc):
if not self._iourc or not os.path.isfile(self._iourc):
raise IOUError("A iourc file is necessary to start IOU")
if not self._iouyap or not os.path.exists(self._iouyap):
if not self._iouyap or not os.path.isfile(self._iouyap):
raise IOUError("iouyap is necessary to start IOU")
self._create_netmap_config()