From 1c5815a8444a1f8e8fa406fbced565468fb3d731 Mon Sep 17 00:00:00 2001 From: Steve Strassmann Date: Fri, 10 May 2013 15:11:10 -0400 Subject: [PATCH] per-file log objects --- i18n/execute.py | 14 +++++++++----- i18n/tests/test_validate.py | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/i18n/execute.py b/i18n/execute.py index e55e653ea7..1ff439ef38 100644 --- a/i18n/execute.py +++ b/i18n/execute.py @@ -4,25 +4,28 @@ from config import CONFIGURATION, BASE_DIR LOG = logging.getLogger(__name__) -def execute(command, working_directory=BASE_DIR, log=LOG): +def execute(command, working_directory=BASE_DIR, log=True): """ Executes shell command in a given working_directory. Command is a string to pass to the shell. - The command is logged to log, output is ignored. + log is boolean. If true, the command's invocation string is logged. + Output is ignored. """ if log: - log.info(command) + LOG.info(command) subprocess.call(command.split(' '), cwd=working_directory) -def call(command, working_directory=BASE_DIR, log=LOG): +def call(command, working_directory=BASE_DIR, log=True): """ Executes shell command in a given working_directory. Command is a string to pass to the shell. Returns a tuple of two strings: (stdout, stderr) + log is boolean. If true, the command's invocation string is logged. + """ if log: - log.info(command) + LOG.info(command) p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=working_directory) out, err = p.communicate() return (out, err) @@ -36,6 +39,7 @@ def create_dir_if_necessary(pathname): def remove_file(filename, log=LOG, verbose=True): """ Attempt to delete filename. + log is boolean. If true, removal is logged. Log a warning if file does not exist. Logging filenames are releative to BASE_DIR to cut down on noise in output. """ diff --git a/i18n/tests/test_validate.py b/i18n/tests/test_validate.py index 67057a30e7..7d970c8de2 100644 --- a/i18n/tests/test_validate.py +++ b/i18n/tests/test_validate.py @@ -28,7 +28,7 @@ def validate_po_file(filename, log): raise SkipTest() # Use relative paths to make output less noisy. rfile = os.path.relpath(filename, LOCALE_DIR) - (out, err) = call(['msgfmt','-c', rfile], log=None, working_directory=LOCALE_DIR) + (out, err) = call(['msgfmt','-c', rfile], log=False, working_directory=LOCALE_DIR) if err != '': log.warn('\n'+err)