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 <gentoo-commits+bounces-472314-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1ScUfX-00077N-00
	for garchives@archives.gentoo.org; Thu, 07 Jun 2012 04:50:00 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 9087FE0511;
	Thu,  7 Jun 2012 04:49:41 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id 60587E0512
	for <gentoo-commits@lists.gentoo.org>; Thu,  7 Jun 2012 04:49:41 +0000 (UTC)
Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163])
	(using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 9DD1A1B4012
	for <gentoo-commits@lists.gentoo.org>; Thu,  7 Jun 2012 04:49:40 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by hornbill.gentoo.org (Postfix) with ESMTP id 6586FE5430
	for <gentoo-commits@lists.gentoo.org>; Thu,  7 Jun 2012 04:49:39 +0000 (UTC)
From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" <brian.dolbec@gmail.com>
Message-ID: <1339044147.afb17b0a5bef67fa51e92373fd5043ac27f4c8f2.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: afb17b0a5bef67fa51e92373fd5043ac27f4c8f2
X-VCS-Branch: master
Date: Thu,  7 Jun 2012 04:49:39 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: 4b8910ed-7365-4c8c-9949-0cf71eba4286
X-Archives-Hash: 27966cf66f936654b32d2c08a849d671

commit:     afb17b0a5bef67fa51e92373fd5043ac27f4c8f2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jun  7 04:42:27 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun  7 04:42:27 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=3Dproj/layman.git;a=3D=
commit;h=3Dafb17b0a

Tighten up the code to prevent exceptions and tracebacks if stdout and st=
derr are not of the file type.

---
 layman/output.py |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/layman/output.py b/layman/output.py
index 2fbeaaf..c90fccc 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -29,10 +29,16 @@ class MessageBase(object):
                  error_callback=3DNone
                  ):
         # Where should the error output go? This can also be a file
-        self.error_out =3D err
+        if isinstance(err, file):
+            self.error_out =3D err
+        else:
+            raise Exception("MessageBase: input parameter 'err' must be =
of type: file")
=20
         # Where should the normal output go? This can also be a file
-        self.std_out =3D out
+        if isinstance(out, file):
+            self.std_out =3D out
+        else:
+            raise Exception("MessageBase: input parameter 'out' must be =
of type: file")
=20
         # The higher the level the more information you will get
         self.warn_lev =3D warn_level
@@ -187,10 +193,10 @@ class Message(MessageBase):
             # NOTE: Forced flushing ensures that stdout and stderr
             # stay in nice order.  This is a workaround for calls like
             # "layman -L |& less".
-            sys.stdout.flush()
+            self.std_out.flush()
             self.error_out.flush()
             print >> self.std_out, " %s %s" % (self.color_func('red', '*=
'), i)
-            sys.stdout.flush()
+            self.std_out.flush()
         self.do_error_callback(error)
=20
=20