summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Guenther <agx@sigxcpu.org>2007-11-19 18:46:24 +0100
committerGuido Guenther <agx@sigxcpu.org>2007-11-19 18:46:24 +0100
commit124a9663ddbbcde0e6ec98e0238fe9d7096ec01f (patch)
tree936f0fd4419bea62798d3937a59351482af8d730
parent4273761a80cb2f216d56841cecaaf18f1d42ea64 (diff)
downloadgit-buildpackage-124a9663ddbbcde0e6ec98e0238fe9d7096ec01f.tar.gz
git-buildpackage-124a9663ddbbcde0e6ec98e0238fe9d7096ec01f.tar.bz2
git-buildpackage-124a9663ddbbcde0e6ec98e0238fe9d7096ec01f.zip
wrap Command class to execute in a specific directory
-rw-r--r--gbp/command_wrappers.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py
index 23086605..f025dfeb 100644
--- a/gbp/command_wrappers.py
+++ b/gbp/command_wrappers.py
@@ -54,6 +54,19 @@ class Command(object):
raise CommandExecFailed
+class RunAtCommand(Command):
+ """Run a command in a specific directory"""
+ def __call__(self, dir='.', *args):
+ curdir = os.path.abspath(os.path.curdir)
+ try:
+ os.chdir(dir)
+ Command.__call__(self, list(*args))
+ os.chdir(curdir)
+ except Exception:
+ os.chdir(curdir)
+ raise
+
+
class UnpackTarArchive(Command):
"""Wrap tar to Unpack a gzipped tar archive"""
def __init__(self, archive, dir, filter=""):