diff --git a/python/damask/test/test.py b/python/damask/test/test.py index e2ef89330..e7f2da14a 100644 --- a/python/damask/test/test.py +++ b/python/damask/test/test.py @@ -267,7 +267,7 @@ class Test(): logging.critical('Current2Current: Unable to copy file "{}"'.format(f)) raise - def execute_inCurrentDir(self,cmd,streamIn=None): + def execute_inCurrentDir(self,cmd,streamIn=None,env=None): logging.info(cmd) out,error = damask.util.execute(cmd,streamIn,self.dirCurrent()) diff --git a/python/damask/util.py b/python/damask/util.py index 189f08a98..27babf43f 100644 --- a/python/damask/util.py +++ b/python/damask/util.py @@ -97,14 +97,17 @@ def strikeout(what): # ----------------------------- def execute(cmd, streamIn = None, - wd = './'): + wd = './', + env = None): """Executes a command in given directory and returns stdout and stderr for optional stdin""" initialPath = os.getcwd() os.chdir(wd) + myEnv = os.environ if env is None else env process = subprocess.Popen(shlex.split(cmd), stdout = 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 else process.communicate(streamIn.read().encode('utf-8')))] out = out.decode('utf-8').replace('\x08','')