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