import os, sys, re, socket
#import commands
from server import Server
-from salome_utils import getHostName
+from salome_utils import getHostName, makeDir
from launchConfigureParser import verbose
# -----------------------------------------------------------------------------
def initNSArgs(self):
from salome_utils import getLogDir
upath = getLogDir()
- try:
- os.makedirs(upath, mode=0o777)
- except:
- pass
+ makeDir(upath)
if verbose(): print("Name Service... ", end =' ')
hname = getHostName()
# ---
+def makeDir(path, mode=0o777):
+ """
+ Make directory with the specified path.
+ :param path : directory path
+ :param mode : access mode
+ """
+ try:
+ oldmask = os.umask(0)
+ os.makedirs(path, mode=mode, exist_ok=True)
+ except IOError:
+ pass
+ finally:
+ os.umask(oldmask)
+
+# ---
+
def makeTmpDir(path, mode=0o777):
"""
Make temporary directory with the specified path.
:param path : directory path
:param mode : access mode
"""
- with suppress(OSError):
- os.makedirs(path, mode=mode, exist_ok=True)
+ makeDir(path, mode)
cleanDir(path)
# ---