mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Use the FileExistsError exception.
This commit is contained in:
1 parent
a874b63e40
commit
872515fa78
6 files changed
+42
-42
No files matched your search
@@ -201,8 +201,9 @@ class IOU(IModule):
|
||||
log.info("iouyap path set to {}".format(self._iouyap))
|
||||
|
||||
if "working_dir" in request:
|
||||
if self._working_dir != request["working_dir"]:
|
||||
self._working_dir = request["working_dir"]
|
||||
new_working_dir = os.path.join(request["working_dir"], "iou")
|
||||
if self._working_dir != new_working_dir:
|
||||
self._working_dir = new_working_dir
|
||||
log.info("this server is local with working directory path to {}".format(self._working_dir))
|
||||
for iou_id in self._iou_instances:
|
||||
iou_instance = self._iou_instances[iou_id]
|
||||
@@ -246,11 +247,12 @@ class IOU(IModule):
|
||||
iou_path = request["path"]
|
||||
|
||||
try:
|
||||
if not os.path.isdir(self._working_dir):
|
||||
try:
|
||||
os.makedirs(self._working_dir)
|
||||
except OSError as e:
|
||||
raise IOUError("Could not create working directory {}".format(e))
|
||||
try:
|
||||
os.makedirs(self._working_dir)
|
||||
except FileExistsError:
|
||||
pass
|
||||
except OSError as e:
|
||||
raise IOUError("Could not create working directory {}".format(e))
|
||||
|
||||
iou_instance = IOUDevice(iou_path, self._working_dir, host=self._host, name=name)
|
||||
# find a console port
|
||||
|
||||
@@ -246,11 +246,12 @@ class IOUDevice(object):
|
||||
|
||||
# create our own working directory
|
||||
working_dir = os.path.join(working_dir, "device-{}".format(self._id))
|
||||
if not os.path.isdir(working_dir):
|
||||
try:
|
||||
os.makedirs(working_dir)
|
||||
except OSError as e:
|
||||
raise IOUError("Could not create working directory {}: {}".format(working_dir, e))
|
||||
try:
|
||||
os.makedirs(working_dir)
|
||||
except FileExistsError:
|
||||
pass
|
||||
except OSError as e:
|
||||
raise IOUError("Could not create working directory {}: {}".format(working_dir, e))
|
||||
|
||||
self._working_dir = working_dir
|
||||
log.info("IOU {name} [id={id}]: working directory changed to {wd}".format(name=self._name,
|
||||
|
||||
Reference in new issue
Block a user