self.err_str = err_str
self.status = status
-def invoke(args, expect=(0,)):
+def invoke(args, expect=(0,), cwd=None):
+ q = Popen(args, stdout=PIPE, stderr=PIPE, cwd=cwd)
+ if sys.platform != "win32":
- q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
++ q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=cwd)
+ else:
+ # win32 don't have os.execvp() so have to run command in a shell
- q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)
- output = q.stdout.read()
- error = q.stderr.read()
++ q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True,
++ cwd=cwd)
+ output, error = q.communicate()
status = q.wait()
if status not in expect:
raise CommandError(error, status)