diff options
author | Guido Günther <agx@sigxcpu.org> | 2013-04-27 22:02:18 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2013-04-27 22:06:20 +0200 |
commit | a949f93396a01ede202f5c5629e53ae8c8d4877f (patch) | |
tree | a3696195a94a666a225117e4ed40fe00ca69e36a /gbp/command_wrappers.py | |
parent | 4d0cc42868f48dc6ec73d0bf89eefd90c1139db1 (diff) |
command_wrappers: allow to silence __call__
and use that in the doctest to get rid of the spurious output
Diffstat (limited to 'gbp/command_wrappers.py')
-rw-r--r-- | gbp/command_wrappers.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py index cc6cebc3..47ad27be 100644 --- a/gbp/command_wrappers.py +++ b/gbp/command_wrappers.py @@ -67,7 +67,7 @@ class Command(object): return subprocess.call(cmd, cwd=self.cwd, shell=self.shell, env=self.env, preexec_fn=default_sigpipe) - def __run(self, args): + def __run(self, args, quiet=False): """ run self.cmd adding args as additional arguments @@ -84,24 +84,24 @@ class Command(object): except OSError as err: err_detail = "Execution failed: %s" % err retcode = 1 - if retcode: + if retcode and not quiet: log.err("%s: %s" % (self.run_error, err_detail)) self.retcode = retcode return retcode - def __call__(self, args=[]): + def __call__(self, args=[], quiet=False): """ Run the command, convert all errors into CommandExecFailed, assumes that the lower levels printed an error message - only useful if you only expect 0 as result. >>> Command("/bin/true")(["foo", "bar"]) - >>> Command("/foo/bar")() + >>> Command("/foo/bar")(quiet=True) Traceback (most recent call last): ... CommandExecFailed """ - if self.__run(args): + if self.__run(args, quiet): raise CommandExecFailed def call(self, args): |