From: Guido Günther Date: Wed, 29 Dec 2010 19:49:03 +0000 (+0100) Subject: Use logging functions X-Git-Tag: debian/0.5.14~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d5230651d108dabbe632b505dc0c89bc77ff561c;p=tools%2Fgit-buildpackage.git Use logging functions --- 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")()