Use the FileExistsError exception.

This commit is contained in:
grossmj committed 2014-04-12 16:46:02 -06:00
1 parent a874b63e40
commit 872515fa78
6 files changed
+42 -42

No files matched your search

+7 -6
View File
@@ -78,12 +78,13 @@ class Server(object):
self._projects_dir = os.path.expandvars(os.path.expanduser(server_config.get("projects_directory", "~/Documents/GNS3/projects")))
self._temp_dir = server_config.get("temporary_directory", tempfile.gettempdir())
if not os.path.isdir(self._projects_dir):
try:
os.makedirs(self._projects_dir)
log.info("projects directory '{}' created".format(self._projects_dir))
except OSError as e:
log.error("could not create the projects directory {}: {}".format(self._projects_dir, e))
try:
os.makedirs(self._projects_dir)
log.info("projects directory '{}' created".format(self._projects_dir))
except FileExistsError:
pass
except OSError as e:
log.error("could not create the projects directory {}: {}".format(self._projects_dir, e))
def load_modules(self):
"""