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 88C7013888F for ; Sun, 11 Oct 2015 17:26:45 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 819FDE0854; Sun, 11 Oct 2015 17:26:42 +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 A1512E0856 for ; Sun, 11 Oct 2015 17:26:41 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DE33D33FEB1 for ; Sun, 11 Oct 2015 17:26:40 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C2A60DF7 for ; Sun, 11 Oct 2015 17:26:37 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1444521277.062b87828d115bbea0dd6b2cefa35902db18f336.vapier@gentoo> Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/support.py X-VCS-Directories: catalyst/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 062b87828d115bbea0dd6b2cefa35902db18f336 X-VCS-Branch: master Date: Sun, 11 Oct 2015 17:26:37 +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: d21d9b3a-c40c-4d13-9083-e70eacb71394 X-Archives-Hash: e6d6aeb3a6f78f9e5d2a12c05a11e8b8 commit: 062b87828d115bbea0dd6b2cefa35902db18f336 Author: Mike Frysinger gentoo org> AuthorDate: Sat Oct 10 05:20:05 2015 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sat Oct 10 23:54:37 2015 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=062b8782 support: convert to log module catalyst/support.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/catalyst/support.py b/catalyst/support.py index 6b1e727..8883acb 100644 --- a/catalyst/support.py +++ b/catalyst/support.py @@ -4,10 +4,10 @@ import sys import os import types import re -import traceback import time from subprocess import Popen +from catalyst import log from catalyst.defaults import valid_config_file_values BASH_BINARY = "/bin/bash" @@ -29,21 +29,13 @@ def list_bashify(mylist): class CatalystError(Exception): def __init__(self, message, print_traceback=False): if message: - if print_traceback: - (_type, value) = sys.exc_info()[:2] - if value!=None: - print - print "Traceback values found. listing..." - print traceback.print_exc(file=sys.stdout) - print - print "!!! catalyst: "+message - print + log.error('CatalystError: %s', message, exc_info=print_traceback) def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None): if env is None: env = {} - #print "***** cmd()" + log.debug('cmd: %r', mycmd) sys.stdout.flush() args=[BASH_BINARY] if "BASH_ENV" not in env: @@ -54,12 +46,11 @@ def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None): args.append("-c") args.append(mycmd) - if debug: - print "***** cmd(); args =", args + log.debug('args: %r', args) proc = Popen(args, env=env) if proc.wait() != 0: if fail_func: - print "CMD(), NON-Zero command return. Running fail_func()" + log.error('CMD(), NON-Zero command return. Running fail_func().') fail_func() raise CatalystError("cmd() NON-zero return value from: %s" % myexc, print_traceback=False) @@ -223,15 +214,17 @@ def addl_arg_parse(myspec,addlargs,requiredspec,validspec): def countdown(secs=5, doing="Starting"): if secs: - print ">>> Waiting",secs,"seconds before starting..." - print ">>> (Control-C to abort)...\n"+doing+" in: ", + sys.stdout.write( + ('>>> Waiting %s seconds before starting...\n' + '>>> (Control-C to abort)...\n' + '%s in: ') % (secs, doing)) ticks=range(secs) ticks.reverse() for sec in ticks: sys.stdout.write(str(sec+1)+" ") sys.stdout.flush() time.sleep(1) - print + sys.stdout.write('\n') def normpath(mypath):