From: vsr Date: Thu, 22 Apr 2021 15:10:27 +0000 (+0300) Subject: bos #24218 [CEA 24189] Cannot launch SALOME - tmp/logs wrong permissions X-Git-Tag: V9_7_0rc1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c648958af899979a9522f8143fe9ec311794176d;p=modules%2Fkernel.git bos #24218 [CEA 24189] Cannot launch SALOME - tmp/logs wrong permissions --- diff --git a/bin/nameserver.py b/bin/nameserver.py index 58982b877..0b8e41c65 100644 --- a/bin/nameserver.py +++ b/bin/nameserver.py @@ -24,7 +24,7 @@ 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 # ----------------------------------------------------------------------------- @@ -40,10 +40,7 @@ class NamingServer(Server): 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() diff --git a/bin/salome_utils.py b/bin/salome_utils.py index df4a49eb5..e919b2484 100644 --- a/bin/salome_utils.py +++ b/bin/salome_utils.py @@ -325,6 +325,22 @@ def cleanDir(path): # --- +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. @@ -332,8 +348,7 @@ def makeTmpDir(path, mode=0o777): :param path : directory path :param mode : access mode """ - with suppress(OSError): - os.makedirs(path, mode=mode, exist_ok=True) + makeDir(path, mode) cleanDir(path) # ---