diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-10-21 18:45:58 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-10-21 21:10:45 +0200 |
commit | 2eafa6aeb540c788a6d0c89aa1cfc8bed7ebb360 (patch) | |
tree | 116c96bcb93282e442d88fc797c931817380a3af /gbp | |
parent | 9e3602e10cc878ac4e7f4718beb0016e936f3ac2 (diff) |
Add cwd option to gbp.command_wrappers.Command
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/command_wrappers.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py index 6b1c834..dd7bc4c 100644 --- a/gbp/command_wrappers.py +++ b/gbp/command_wrappers.py @@ -36,12 +36,14 @@ class Command(object): Wraps a shell command, so we don't have to store any kind of command line options in one of the git-buildpackage commands """ - def __init__(self, cmd, args=[], shell=False, extra_env=None): + + def __init__(self, cmd, args=[], shell=False, extra_env=None, cwd=None): self.cmd = cmd self.args = args self.run_error = "Couldn't run '%s'" % (" ".join([self.cmd] + self.args)) self.shell = shell self.retcode = 1 + self.cwd = cwd if extra_env is not None: self.env = os.environ.copy() self.env.update(extra_env) @@ -58,7 +60,8 @@ class Command(object): cmd = [ self.cmd ] + self.args + args if self.shell: # subprocess.call only cares about the first argument if shell=True cmd = " ".join(cmd) - return subprocess.call(cmd, shell=self.shell, env=self.env, preexec_fn=default_sigpipe) + return subprocess.call(cmd, cwd=self.cwd, shell=self.shell, + env=self.env, preexec_fn=default_sigpipe) def __run(self, args): """ |