enable to explicitly set the environment
required for running MPI processes when mpi4py is imported
This commit is contained in:
parent
4ef66b4e28
commit
cede188e76
|
@ -267,7 +267,7 @@ class Test():
|
||||||
logging.critical('Current2Current: Unable to copy file "{}"'.format(f))
|
logging.critical('Current2Current: Unable to copy file "{}"'.format(f))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def execute_inCurrentDir(self,cmd,streamIn=None):
|
def execute_inCurrentDir(self,cmd,streamIn=None,env=None):
|
||||||
|
|
||||||
logging.info(cmd)
|
logging.info(cmd)
|
||||||
out,error = damask.util.execute(cmd,streamIn,self.dirCurrent())
|
out,error = damask.util.execute(cmd,streamIn,self.dirCurrent())
|
||||||
|
|
|
@ -97,14 +97,17 @@ def strikeout(what):
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
def execute(cmd,
|
def execute(cmd,
|
||||||
streamIn = None,
|
streamIn = None,
|
||||||
wd = './'):
|
wd = './',
|
||||||
|
env = None):
|
||||||
"""Executes a command in given directory and returns stdout and stderr for optional stdin"""
|
"""Executes a command in given directory and returns stdout and stderr for optional stdin"""
|
||||||
initialPath = os.getcwd()
|
initialPath = os.getcwd()
|
||||||
os.chdir(wd)
|
os.chdir(wd)
|
||||||
|
myEnv = os.environ if env is None else env
|
||||||
process = subprocess.Popen(shlex.split(cmd),
|
process = subprocess.Popen(shlex.split(cmd),
|
||||||
stdout = subprocess.PIPE,
|
stdout = subprocess.PIPE,
|
||||||
stderr = subprocess.PIPE,
|
stderr = subprocess.PIPE,
|
||||||
stdin = subprocess.PIPE)
|
stdin = subprocess.PIPE,
|
||||||
|
env = myEnv)
|
||||||
out,error = [i for i in (process.communicate() if streamIn is None
|
out,error = [i for i in (process.communicate() if streamIn is None
|
||||||
else process.communicate(streamIn.read().encode('utf-8')))]
|
else process.communicate(streamIn.read().encode('utf-8')))]
|
||||||
out = out.decode('utf-8').replace('\x08','')
|
out = out.decode('utf-8').replace('\x08','')
|
||||||
|
|
Loading…
Reference in New Issue