From c648958af899979a9522f8143fe9ec311794176d Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 22 Apr 2021 18:10:27 +0300 Subject: [PATCH] bos #24218 [CEA 24189] Cannot launch SALOME - tmp/logs wrong permissions --- bin/nameserver.py | 7 ++----- bin/salome_utils.py | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) 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) # --- -- 2.39.2