From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id BBF53138247 for ; Wed, 22 Jan 2014 05:04:30 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 79406E1174; Wed, 22 Jan 2014 05:04:17 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5C940E1174 for ; Wed, 22 Jan 2014 05:04:16 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 44DCA33FAF7 for ; Wed, 22 Jan 2014 05:04:15 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id 7524A187D0 for ; Wed, 22 Jan 2014 05:04:13 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1390365361.4fc05408af380d443178943f3194b485da92f6b8.dol-sen@gentoo> Subject: [gentoo-commits] proj/catalyst:3.0 commit in: catalyst/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/support.py X-VCS-Directories: catalyst/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 4fc05408af380d443178943f3194b485da92f6b8 X-VCS-Branch: 3.0 Date: Wed, 22 Jan 2014 05:04:13 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 3770e743-51f3-4bae-9390-c4d777be66d4 X-Archives-Hash: 2677b9c003eea24f222761faf324134d commit: 4fc05408af380d443178943f3194b485da92f6b8 Author: Brian Dolbec gentoo org> AuthorDate: Wed Jan 22 01:55:04 2014 +0000 Commit: Brian Dolbec gmail com> CommitDate: Wed Jan 22 04:36:01 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=4fc05408 Take most cmd() code out to the try: except: pairs --- catalyst/support.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/catalyst/support.py b/catalyst/support.py index 3db1509..cafb5d2 100644 --- a/catalyst/support.py +++ b/catalyst/support.py @@ -120,25 +120,29 @@ def find_binary(myc): return None -def cmd(mycmd, myexc="", env={}, debug=False): +def cmd(mycmd, myexc="", env={}, debug=False, fail_func=None): + #print "***** cmd()" + sys.stdout.flush() + args=[BASH_BINARY] + if "BASH_ENV" not in env: + env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env" + if debug: + args.append("-x") + args.append("-c") + args.append(mycmd) + + #if debug: + print "***** cmd(); args =", args try: - sys.stdout.flush() - args=[BASH_BINARY] - if "BASH_ENV" not in env: - env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env" - if debug: - args.append("-x") - args.append("-c") - args.append(mycmd) - - #if debug: - print "***** cmd(); args =", args proc = Popen(args, env=env) - if proc.wait() != 0: - raise CatalystError("cmd() NON-zero return value from: %s" % myexc, - print_traceback=False) except: raise + if proc.wait() != 0: + if fail_func: + print "CMD(), NON-Zero command return. Running fail_func()" + fail_func() + raise CatalystError("cmd() NON-zero return value from: %s" % myexc, + print_traceback=False) def file_locate(settings,filelist,expand=1):