1 |
commit: 062b87828d115bbea0dd6b2cefa35902db18f336 |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Oct 10 05:20:05 2015 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Oct 10 23:54:37 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=062b8782 |
7 |
|
8 |
support: convert to log module |
9 |
|
10 |
catalyst/support.py | 27 ++++++++++----------------- |
11 |
1 file changed, 10 insertions(+), 17 deletions(-) |
12 |
|
13 |
diff --git a/catalyst/support.py b/catalyst/support.py |
14 |
index 6b1e727..8883acb 100644 |
15 |
--- a/catalyst/support.py |
16 |
+++ b/catalyst/support.py |
17 |
@@ -4,10 +4,10 @@ import sys |
18 |
import os |
19 |
import types |
20 |
import re |
21 |
-import traceback |
22 |
import time |
23 |
from subprocess import Popen |
24 |
|
25 |
+from catalyst import log |
26 |
from catalyst.defaults import valid_config_file_values |
27 |
|
28 |
BASH_BINARY = "/bin/bash" |
29 |
@@ -29,21 +29,13 @@ def list_bashify(mylist): |
30 |
class CatalystError(Exception): |
31 |
def __init__(self, message, print_traceback=False): |
32 |
if message: |
33 |
- if print_traceback: |
34 |
- (_type, value) = sys.exc_info()[:2] |
35 |
- if value!=None: |
36 |
- print |
37 |
- print "Traceback values found. listing..." |
38 |
- print traceback.print_exc(file=sys.stdout) |
39 |
- print |
40 |
- print "!!! catalyst: "+message |
41 |
- print |
42 |
+ log.error('CatalystError: %s', message, exc_info=print_traceback) |
43 |
|
44 |
|
45 |
def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None): |
46 |
if env is None: |
47 |
env = {} |
48 |
- #print "***** cmd()" |
49 |
+ log.debug('cmd: %r', mycmd) |
50 |
sys.stdout.flush() |
51 |
args=[BASH_BINARY] |
52 |
if "BASH_ENV" not in env: |
53 |
@@ -54,12 +46,11 @@ def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None): |
54 |
args.append("-c") |
55 |
args.append(mycmd) |
56 |
|
57 |
- if debug: |
58 |
- print "***** cmd(); args =", args |
59 |
+ log.debug('args: %r', args) |
60 |
proc = Popen(args, env=env) |
61 |
if proc.wait() != 0: |
62 |
if fail_func: |
63 |
- print "CMD(), NON-Zero command return. Running fail_func()" |
64 |
+ log.error('CMD(), NON-Zero command return. Running fail_func().') |
65 |
fail_func() |
66 |
raise CatalystError("cmd() NON-zero return value from: %s" % myexc, |
67 |
print_traceback=False) |
68 |
@@ -223,15 +214,17 @@ def addl_arg_parse(myspec,addlargs,requiredspec,validspec): |
69 |
|
70 |
def countdown(secs=5, doing="Starting"): |
71 |
if secs: |
72 |
- print ">>> Waiting",secs,"seconds before starting..." |
73 |
- print ">>> (Control-C to abort)...\n"+doing+" in: ", |
74 |
+ sys.stdout.write( |
75 |
+ ('>>> Waiting %s seconds before starting...\n' |
76 |
+ '>>> (Control-C to abort)...\n' |
77 |
+ '%s in: ') % (secs, doing)) |
78 |
ticks=range(secs) |
79 |
ticks.reverse() |
80 |
for sec in ticks: |
81 |
sys.stdout.write(str(sec+1)+" ") |
82 |
sys.stdout.flush() |
83 |
time.sleep(1) |
84 |
- print |
85 |
+ sys.stdout.write('\n') |
86 |
|
87 |
|
88 |
def normpath(mypath): |