aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/util/subproc.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@tremily.us>2013-01-24 02:31:52 -0500
committerW. Trevor King <wking@tremily.us>2013-01-24 02:36:22 -0500
commit932679f1e82a57feb4743e52d6c60f7331f057c2 (patch)
tree21c014cf36c8c159b7e5bf4627abf94b2e7a371b /libbe/util/subproc.py
parent182a556397c2b0f4638991942c736c5daff17111 (diff)
downloadbugseverywhere-932679f1e82a57feb4743e52d6c60f7331f057c2.tar.gz
Transition to libbe.LOG for logging
This makes it easier to tweak log verbosity and redirect logs to other handlers. For example, the WSGI servers are unstable with stderr closed, and crash with an IOError if they try to print a warning to stderr.
Diffstat (limited to 'libbe/util/subproc.py')
-rw-r--r--libbe/util/subproc.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/libbe/util/subproc.py b/libbe/util/subproc.py
index 08980c9..f1f04c1 100644
--- a/libbe/util/subproc.py
+++ b/libbe/util/subproc.py
@@ -47,8 +47,7 @@ class CommandError(Exception):
self.stderr = stderr
def invoke(args, stdin=None, stdout=PIPE, stderr=PIPE, expect=(0,),
- cwd=None, shell=None, unicode_output=True, verbose=False,
- encoding=None, **kwargs):
+ cwd=None, shell=None, unicode_output=True, encoding=None, **kwargs):
"""
expect should be a tuple of allowed exit codes. cwd should be
the directory from which the command will be executed. When
@@ -63,8 +62,7 @@ def invoke(args, stdin=None, stdout=PIPE, stderr=PIPE, expect=(0,),
else:
list_args = args
str_args = ' '.join(args) # sloppy, but just for logging
- if verbose == True:
- print >> sys.stderr, '%s$ %s' % (cwd, str_args)
+ libbe.LOG.debug('{0}$ {1}'.format(cwd, str_args))
try :
if _POSIX:
if shell is None:
@@ -89,8 +87,7 @@ def invoke(args, stdin=None, stdout=PIPE, stderr=PIPE, expect=(0,),
stdout = unicode(stdout, encoding)
if stderr != None:
stderr = unicode(stderr, encoding)
- if verbose == True:
- print >> sys.stderr, '%d\n%s%s' % (status, stdout, stderr)
+ libbe.LOG.debug('{0}\n{1}{2}'.format(status, stdout, stderr))
if status not in expect:
raise CommandError(list_args, status, stdout, stderr)
return status, stdout, stderr