Georg Baum wrote:
Helge Hafting wrote:
Lyx discovered the existence of a converter, invoked
lilypond which ran without error messages, but then
lyx (using -dbg external,graphics) claimed that no
file was produced. Very strange that. Note that
I don't actually tell lilypond where to put the output file,
but lilypond will then put it where it finds the
input file.
No, it will put it in the current directory (at least version 2.4.4)
I believe I tested this with a path, and it worked for
lilypond 2.9.17 which I use. I will re-test though.
Maybe it works for .pdf but not .png. . .
There was no such file in the temp directory,
perhaps it got deleted somehow? The apprach worked
so well for .eps and .pdf, and of course I tested the
command on the command line too.
I have an older version of lilypond, and I had to modify the converters to
try it out, but what happens for me is this: Regardless of any -o parameter
you give, the output is always generated in the current directory. Have a
look at the directory where you started LyX from. Does it contain the
gconvert* files?
There are indeed some gconvert-files there, but mostly
lilypond's intermediate files. If lilypond drops litters "current
directory" with such files, then perhaps a python script
doing a chdir to /tmp is the way to go?
What you could do is to copy the files from the current direrctory to the
temp directory in the python script. That should work. And of course you
should file a bug report to lilypond if your version still ignores the
directory part of the -o parameter.
So what the hell is this "syntax error in lyxconvert7.py" business ???
This is an automatically generated script that should of course never have a
syntax error. See src/graphics/GraphicsConverter.C.
Can you please send the script (it is copied to debug output for -dbg
graphics)?
I changed this script recently, also for 1.4.3. For me it works fine, but
I'd like to iron out corner case bugs if they exist.
Bugs is what we have 1.5svn for. Debug output with script:
The file contains ly format data.
Unable to convert from ly to bmp
Unable to convert from ly to gif
Unable to convert from ly to jpg
Unable to convert from ly to pbm
Unable to convert from ly to pgm
Converting it to png format.
Converter c-tor:
from_file: /home/helgehaf/test/music/t8.ly
to_file_base: /tmp/lyx_tmpdir21606Bhlxjl/CacheItem21606zRhduj
from_format: ly
to_format: png
build_script ... ready!
Conversion script:
--------------------------------------
#!/usr/bin/env python -tt
import os, shutil, sys
def unlinkNoThrow(file):
''' remove a file, do not throw if an error occurs '''
try:
os.unlink(file)
except:
pass
infile = '/home/helgehaf/test/music/t8.ly'
outfile = '/tmp/lyx_tmpdir21606Bhlxjl/gconvert021606h0l85m.ly'
shutil.copy(infile, outfile)
infile = '/tmp/lyx_tmpdir21606Bhlxjl/gconvert021606h0l85m.ly'
infile_base = '/tmp/lyx_tmpdir21606Bhlxjl/gconvert021606h0l85m'
outfile = '/tmp/lyx_tmpdir21606Bhlxjl/gconvert021606h0l85m.png'
if os.system(r'python -tt '/usr/local/share/lyx/scripts/ly2png.py' ' +
'"' + infile + '"' + ' ' + '"' + outfile + '"' + '') != 0:
unlinkNoThrow(outfile)
sys.exit(1)
if not os.path.isfile(outfile):
if os.path.isfile(outfile + '.0'):
os.rename(outfile + '.0', outfile)
import glob
for file in glob.glob(outfile + '.?'):
unlinkNoThrow(file)
else:
sys.exit(1)
unlinkNoThrow(infile)
fromfile = outfile
tofile = '/tmp/lyx_tmpdir21606Bhlxjl/CacheItem21606zRhduj.png'
try:
os.rename(fromfile, tofile)
except:
try:
shutil.copy(fromfile, tofile)
except:
sys.exit(1)
unlinkNoThrow(fromfile)
--------------------------------------
ForkedCallQueue: waking up
LoaderQueue: I'm going to sleep
File "/tmp/lyx_tmpdir21606Bhlxjl/lyxconvert0.py", line 18
if os.system(r'python -tt '/usr/local/share/lyx/scripts/ly2png.py' '
+ '"' + infile + '"' + ' ' + '"' + outfile + '"' + '') != 0:
^
SyntaxError: invalid syntax
ForkedCallQueue: I'm going to sleep
Image conversion failed.
Unable to find converted file!
There is that "r" in the beginning of the os.system() call which looks
suspicious to me. I don't know much python, but it sure looks odd.
Anyway, the external inset with .pdf and .eps converters is all that
is needed to use this for output, so here it is so you may consider
it for inclusion or ask for improvements:
I'd like to include that after some polishing.
My polishing plan:
1. Rename the format from "ly" to "LilyPond", that says much more.
There may be other programs using .ly sometime.
2. Check carefully where lilypond stores intermediate and
final files. Use scripts if necessary to force use of /tmp.
This worked for .pdf and .eps though, view->dvi and view->pdf(pdflatex)
did not protest about missing files.
Attached preferences.diff, which defines the file format and converters
Attached external.diff, which defines the external template
for lilypond.
Can you explain what the -b and -d arguments do? My version of lilypond does
not have them.
lilypond -v
GNU LilyPond 2.9.17
lilypond -h
GNU LilyPond 2.9.17
Usage: lilypond [OPTION]... FILE...
Typeset music and/or produce MIDI from FILE.
LilyPond produces beautiful music notation.
For more information, see http://lilypond.org
Options:
-b, --backend=BACK use backend BACK (gnome, ps,eps,
scm, svg, tex, texstr)
default: PS
-d, --define-default=SYM=VAL set a Scheme program option. Uses #t
if VAL is not specified
Try -dhelp for help.
-e, --evaluate=EXPR evaluate scheme code
-f, --formats=FORMATs dump FORMAT,... Also as separate
options:
--dvi generate DVI (tex backend only)
--relocate relocate using directory of lilypond
program
--pdf generate PDF (default)
--png generate PNG
--ps generate PostScript
--tex generate TeX (tex backend only)
-h, --help print this help
-H, --header=FIELD dump a header field to file
BASENAME.FIELD
-I, --include=DIR add DIR to search path
-i, --init=FILE use FILE as init file
-j, --jail=USER,GROUP,JAIL,DIR chroot to JAIL, become USER:GROUP
and cd into DIR
--no-print do not generate printed output
-o, --output=FILE write output to FILE (suffix will be
added)
-p, --preview generate a preview of the first system
-s, --safe-mode disallow unsafe Scheme and PostScript
operations
-v, --version print version number
-V, --verbose be verbose
-w, --warranty show warranty and copyright
Report bugs via
http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs
I had some trouble getting an acceptable .eps file, I believe
that was when I introduced "-b eps".
The "-d" parameter sets some values. I don't know it well,
but I found the example on the lilypond site. I'll try removing
it and see if it still works.
Do you know what lilypond versions are in common use?
Debian's lilypond is very old, that's why I downloaded from the
lilypond site. Installing in /usr/local was easy enough, just run
the downloaded install-script as root and that's it.
It'd be nice to support older versions, although I consider it
important that it works with the newest too.
What did you need to change in the converters - just remove
-b and -d, or more?
Helge Hafting