lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make doc


From: Phil Holmes
Subject: Re: make doc
Date: Thu, 2 Jun 2011 18:31:47 +0100

----- Original Message ----- From: "Graham Percival" <address@hidden>
To: "Phil Holmes" <address@hidden>
Cc: <address@hidden>
Sent: Wednesday, June 01, 2011 3:38 PM
Subject: Re: make doc


On Wed, Jun 01, 2011 at 03:27:14PM +0100, Phil Holmes wrote:

----- Original Message ----- From: "Graham Percival"
<address@hidden>
>If that's true, then maybe this should be added.  It'd be another
>of those 5-lines patches that takes 5 hours to write, though.

I don't think so - to do this, I'd propose to add a flag to
lilypond-book, -r.  If the -r flag is present, l-book would redirect
all output from compiling 1234abcd.ly to 1234abcd.log in the same
directory as the input file.  You OK with that?

That would be absolutely ideal!  I'm not totally sold on using -r
since that tends to be used for "recursive".  How about just make
it --redirect-lilypond-output ?  This isn't a command that people
will need to type by hand a lot (or even), so I think a
long+descriptive name would be perfect.


I've concluded that your "5 lines takes 5 hours" is close to the truth. To make lilypond-book redirect lilypond output is non-trivial, but I now know how. It means editing lilylib.py, but only to make an existing option functional. Here's my notes about how this would be done. I'm guessing your response will be - go ahead, submit a patch to Rietveld...

We need to edit lilypond-book.  The relevant line is:

system_in_directory (' '.join ([cmd, ly.mkarg (name)]),
                        lily_output_dir)

This concatenates the lilypond-run command with the filename to be
compiled and supplies this as the first arg to a function that
runs a system command, like this:

ly.system(cmd, be_verbose=global_options.verbose,
             progress_p=1)

The system command is found in lilylib.py:

system = subprocess_system
if sys.platform == 'mingw32':
   ## subprocess x-compile doesn't work.
   system = ossystem_system

and elsewhere in the file:

def subprocess_system (cmd,
                      ignore_error=False,
                      progress_p=True,
                      be_verbose=False,
                      log_file=None):

That's interesting - it already has a log_file parameter - which
isn't used....  Currently the non-windows version has this:

   stdout_setting = None
   if not show_progress:
       stdout_setting = subprocess.PIPE

   proc = subprocess.Popen (cmd,
       shell=True,
       universal_newlines=True,
       stdout=stdout_setting,
       stderr=stdout_setting)

If we change this to something like:

   out = open('stdout.txt', 'w')
   proc = subprocess.Popen (cmd,
       shell=True,
       universal_newlines=True,
       stdout=out,
       stderr=out)
   out.close()

we get the output sent to stdout.txt. :-) So all (!) we need to do
is use the log_file parameter (I suggest this should be a string,
not an open file, and to append .log in the opening process above)
to create a file and send the output to.  If we wanted to be
really neat, we could actually have 2 files -
lilyfile.log and lilyfile.error.log

--
Phil Holmes




reply via email to

[Prev in Thread] Current Thread [Next in Thread]