Commit 1c5815a8 by Steve Strassmann

per-file log objects

parent a52cf85c
......@@ -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.
"""
......
......@@ -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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment