Commit aa5fd7fa authored by Maude Le Jeune's avatar Maude Le Jeune
Browse files

add option cwd to subprocess.Popen

parent d5ce387a
......@@ -300,7 +300,7 @@ class Environment(EnvironmentBase):
+glob(path.join(self._worker.pipe.get_data_dir(segx),path.join('*/',y)))
def logged_subprocess(self, args, shell=False, except_on_failure=True, name=None, of=None, stat=False):
def logged_subprocess(self, args, shell=False, except_on_failure=True, name=None, of=None, stat=False, cwd=None):
""" Execute a subprocess and log its output.
Create files process_name.log and process_name.err. If shell is set to True, the command is run via a shell. If except_on_failure set to True, raise an exception when command execution return non zero
......@@ -322,7 +322,7 @@ class Environment(EnvironmentBase):
if stat:
res = resource.getrusage(resource.RUSAGE_CHILDREN)
wall_time = timer()
p=subprocess.Popen(args, stdout=o, stderr=e, shell=shell)
p=subprocess.Popen(args, stdout=o, stderr=e, shell=shell,cwd=cwd)
p.communicate()[0]
if stat:
wall_time = timer() - wall_time
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment