From: Guido Günther Date: Fri, 21 Oct 2011 16:45:58 +0000 (+0200) Subject: Add cwd option to gbp.command_wrappers.Command X-Git-Tag: debian/0.6.0_git20111202~103 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2eafa6aeb540c788a6d0c89aa1cfc8bed7ebb360;p=tools%2Fgit-buildpackage.git Add cwd option to gbp.command_wrappers.Command --- 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): """