From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QF2TF-0003UH-Qw for garchives@archives.gentoo.org; Wed, 27 Apr 2011 10:59:50 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F26CC1C07A; Wed, 27 Apr 2011 10:58:42 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id BEEA51C059 for ; Wed, 27 Apr 2011 10:58:42 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E5B471BC01E for ; Wed, 27 Apr 2011 10:58:41 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id BB2548050B for ; Wed, 27 Apr 2011 10:58:40 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <89455e5de82d644e5b034642bacaac8338e8987a.dol-sen@gentoo> Subject: [gentoo-commits] proj/layman:master commit in: layman/ X-VCS-Repository: proj/layman X-VCS-Files: layman/output.py X-VCS-Directories: layman/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 89455e5de82d644e5b034642bacaac8338e8987a Date: Wed, 27 Apr 2011 10:58:40 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 51d82cc5beebe8a106f135fc17e75464 commit: 89455e5de82d644e5b034642bacaac8338e8987a Author: Brian Dolbec gmail com> AuthorDate: Mon Feb 21 11:38:41 2011 +0000 Commit: Brian Dolbec gmail com> CommitDate: Thu Feb 24 06:49:58 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/layman.git;a=3D= commit;h=3D89455e5d add an error callback function ability to pass errors to. --- layman/output.py | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/layman/output.py b/layman/output.py index 05260ce..469f673 100644 --- a/layman/output.py +++ b/layman/output.py @@ -24,7 +24,8 @@ class MessageBase(object): err =3D sys.stderr, info_level =3D INFO_LEVEL, warn_level =3D WARN_LEVEL, - col =3D True + col =3D True, + error_callback=3DNone ): # Where should the error output go? This can also be a file self.error_out =3D err @@ -44,7 +45,9 @@ class MessageBase(object): =20 self.debug_lev =3D OFF =20 - self.has_error =3D False + # callback function that gets passed any error messages + # that have shown up. + self.error_callback =3D error_callback =20 =20 def _color (self, col, text): @@ -73,6 +76,12 @@ class MessageBase(object): def set_debug_level(self, debugging_level =3D DEBUG_LEVEL): self.debug_lev =3D debugging_level =20 + def do_error_callback(self, error): + """runs the error_callback function with the error + that occurred + """ + if self.error_callback: + self.error_callback(error) =20 =20 class Message(MessageBase): @@ -86,8 +95,9 @@ class Message(MessageBase): err =3D sys.stderr, info_level =3D INFO_LEVEL, warn_level =3D WARN_LEVEL, - col =3D True - ): + col =3D True, + error_callback =3D None + ): =20 MessageBase.__init__(self) =20 @@ -170,7 +180,7 @@ class Message(MessageBase): sys.stdout.flush() print >> self.error_out, self.color_func('red', '* ') + i self.error_out.flush() - self.has_error =3D True + self.do_error_callback(error) =20 =20 def die (self, error):