From d5230651d108dabbe632b505dc0c89bc77ff561c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Guido=20G=C3=BCnther?= Date: Wed, 29 Dec 2010 20:49:03 +0100 Subject: [PATCH] Use logging functions --- gbp/command_wrappers.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py index 60a317f..28f62a0 100644 --- a/gbp/command_wrappers.py +++ b/gbp/command_wrappers.py @@ -7,7 +7,6 @@ git-buildpackage and friends """ import subprocess -import sys import os import os.path import signal @@ -51,25 +50,25 @@ class Command(object): """ run self.cmd adding args as additional arguments - be verbose about errors and encode them in the return value, don't pass - on exceptions + Be verbose about errors and encode them in the return value, don't pass + on exceptions. """ try: retcode = self.__call(args) if retcode < 0: - print >>sys.stderr, "%s was terminated by signal %d" % (self.cmd, -retcode) + log.err("%s was terminated by signal %d" % (self.cmd, -retcode)) elif retcode > 0: - print >>sys.stderr, "%s returned %d" % (self.cmd, retcode) + log.err("%s returned %d" % (self.cmd, retcode)) except OSError, e: - print >>sys.stderr, "Execution failed:", e + log.err("Execution failed: " + e.__str__()) retcode = 1 if retcode: - print >>sys.stderr, self.run_error + log.err(self.run_error) return retcode def __call__(self, args=[]): - """run the command, convert all errors into CommandExecFailed, assumes - that the lower levels printed an error message - only usefull if you + """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")() -- 2.7.4