[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Redirects lilypond output to reduce make doc noise (issue4550119)
From: |
PhilEHolmes |
Subject: |
Redirects lilypond output to reduce make doc noise (issue4550119) |
Date: |
Tue, 07 Jun 2011 14:34:30 +0000 |
Reviewers: Graham Percival,
Message:
Please review this proposed change to the build system.
The change reduces the amount of un-needed information
echoed to the screen during make doc.
Description:
Redirects lilypond output to reduce make doc noise
Redirects the output from lilypond when lily is run from lilypond-book
as part of make doc. Normal output goes to *.log, error output to
*.err.log.
Note that this looks more complex than needed, since redirecting output
appears to stop normal process monitoring, so I've had to use
process.poll.
I have tested this, and a polling rate of once per second does not
slow compilation significantly - most files take 100s of seconds to
compile.
Please review this at http://codereview.appspot.com/4550119/
Affected files:
M make/ly-rules.make
M python/lilylib.py
M scripts/lilypond-book.py
Index: make/ly-rules.make
diff --git a/make/ly-rules.make b/make/ly-rules.make
index
0df0643ee3158ec5ad2c0a685d752942ea30d18e..a876b04f1864ea548e03997b35aecccbed5bbcbd
100644
--- a/make/ly-rules.make
+++ b/make/ly-rules.make
@@ -22,11 +22,11 @@ $(eval $(firstword $(TEXI_FILES_FROM_TELY)):\
# don't do ``cd $(outdir)'', and assume that $(outdir)/.. is the src dir.
# it is not, for --srcdir builds
$(outdir)/%.texi: %.tely $(outdir)/version.itexi
$(DOCUMENTATION_LOCALE_TARGET) $(INIT_LY_SOURCES) $(SCHEME_SOURCES)
- LILYPOND_VERSION=$(TOPLEVEL_VERSION) $(PYTHON) $(LILYPOND_BOOK)
$(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BOOK_PROCESS)
$(LILYPOND_BOOK_LILYPOND_FLAGS)' --output=$(outdir)
--format=$(LILYPOND_BOOK_FORMAT) $(LILYPOND_BOOK_FLAGS) $<
+ LILYPOND_VERSION=$(TOPLEVEL_VERSION) $(PYTHON) $(LILYPOND_BOOK)
$(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BOOK_PROCESS)
$(LILYPOND_BOOK_LILYPOND_FLAGS)' --output=$(outdir)
--format=$(LILYPOND_BOOK_FORMAT) $(LILYPOND_BOOK_FLAGS)
--redirect-lilypond-output $<
$(outdir)/%.texi: $(outdir)/%.tely $(outdir)/version.itexi
$(DOCUMENTATION_LOCALE_TARGET) $(INIT_LY_SOURCES) $(SCHEME_SOURCES)
- LILYPOND_VERSION=$(TOPLEVEL_VERSION) $(PYTHON) $(LILYPOND_BOOK)
$(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BOOK_PROCESS)
$(LILYPOND_BOOK_INCLUDES) $(LILYPOND_BOOK_LILYPOND_FLAGS)'
--output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) $(LILYPOND_BOOK_FLAGS)
$<
+ LILYPOND_VERSION=$(TOPLEVEL_VERSION) $(PYTHON) $(LILYPOND_BOOK)
$(LILYPOND_BOOK_INCLUDES) --process='$(LILYPOND_BOOK_PROCESS)
$(LILYPOND_BOOK_INCLUDES) $(LILYPOND_BOOK_LILYPOND_FLAGS)'
--output=$(outdir) --format=$(LILYPOND_BOOK_FORMAT) $(LILYPOND_BOOK_FLAGS)
--redirect-lilypond-output $<
$(outdir)/%.html.omf: %.tely
Index: python/lilylib.py
diff --git a/python/lilylib.py b/python/lilylib.py
index
6fb96bbbf59959fccdc19a15cd846785a5befb0a..223af43138e01784fc01ab62140633e78e657315
100644
--- a/python/lilylib.py
+++ b/python/lilylib.py
@@ -23,6 +23,7 @@ import re
import shutil
import sys
import optparse
+import time
################################################################
# Users of python modules should include this snippet
@@ -118,6 +119,7 @@ def subprocess_system (cmd,
ignore_error=False,
progress_p=True,
be_verbose=False,
+ redirect_output=False,
log_file=None):
import subprocess
@@ -125,16 +127,25 @@ def subprocess_system (cmd,
name = command_name (cmd)
error_log_file = ''
- if be_verbose:
- show_progress = 1
- progress (_ ("Invoking `%s\'") % cmd)
+ if redirect_output:
+ progress (_ ("Processing %s.ly") % log_file)
else:
- progress ( _("Running %s...") % name)
-
+ if be_verbose:
+ show_progress = 1
+ progress (_ ("Invoking `%s\'") % cmd)
+ else:
+ progress ( _("Running %s...") % name)
stdout_setting = None
+ stderr_setting = None
if not show_progress:
- stdout_setting = subprocess.PIPE
+ stdout_setting = subprocess.PIPE
+
+ if redirect_output:
+ stdout_filename = ' '.join([log_file, '.log'])
+ stderr_filename = ' '.join([log_file, '.err.log'])
+ stdout_setting = open(stdout_filename, 'w')
+ stderr_setting = open(stderr_filename, 'w')
proc = subprocess.Popen (cmd,
shell=True,
@@ -144,11 +155,18 @@ def subprocess_system (cmd,
log = ''
- if show_progress:
- retval = proc.wait()
+ if redirect_output:
+ while proc.poll()==None:
+ time.sleep(1)
+ retval = proc.returncode
+ stdout_setting.close()
+ stderr_setting.close()
else:
- log = proc.communicate ()
- retval = proc.returncode
+ if show_progress:
+ retval = proc.wait()
+ else:
+ log = proc.communicate ()
+ retval = proc.returncode
if retval:
Index: scripts/lilypond-book.py
diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py
index
9617f3666d3a4c878325a089b3d898def9771a8d..a0501cae9e5c8f0eb9e0584a15456372b64046ac
100644
--- a/scripts/lilypond-book.py
+++ b/scripts/lilypond-book.py
@@ -179,6 +179,11 @@ def get_option_parser ():
action='store',
dest='process_cmd', default='')
+ p.add_option ('--redirect-lilypond-output',
+ help = _ ("Redirect the lilypond output"),
+ action='store_true',
+ dest='redirect_output', default=False)
+
p.add_option ('-s', '--safe', help=_ ("Compile snippets in safe mode"),
action="store_true",
default=False,
@@ -347,7 +352,7 @@ def find_toplevel_snippets (input_string, formatter):
return snippets
-def system_in_directory (cmd, directory):
+def system_in_directory (cmd, directory, logfile):
"""Execute a command in a different directory.
Because of win32 compatibility, we can't simply use subprocess.
@@ -355,7 +360,10 @@ def system_in_directory (cmd, directory):
current = os.getcwd()
os.chdir (directory)
- ly.system(cmd, be_verbose=global_options.verbose,
+ ly.system(cmd,
+ be_verbose=global_options.verbose,
+ redirect_output=global_options.redirect_output,
+ log_file=logfile,
progress_p=1)
os.chdir (current)
@@ -374,10 +382,12 @@ def process_snippets (cmd, snippets,
+ list (set ([snip.basename() + '.ly' for snip
in snippets])))
name = os.path.join (lily_output_dir,
'snippet-names-%d.ly' % checksum)
+ logfile = name.replace('.ly', '')
file (name, 'wb').write (contents)
system_in_directory (' '.join ([cmd, ly.mkarg (name)]),
- lily_output_dir)
+ lily_output_dir,
+ logfile)
def snippet_list_checksum (snippets):
- Redirects lilypond output to reduce make doc noise (issue4550119),
PhilEHolmes <=