Menu

#3510 Convert-ly cmdline redirection fails under Windows 7

Accepted
nobody
None
Scripts
2018-09-12
2013-08-20
Anonymous
No

Originally created by: *anonymous

Originally created by: ColinPKC...@gmail.com

Reported by Eluze:
Although AU suggests that convert-ly output can be redirected to preserve the input file, python throws an error under Windows 7:

Traceback (most recent call last):
  File "C:\Program Files (x86)\LilyPond\usr\bin\convert-ly.py", line 386, in ?
    main ()
  File "C:\Program Files (x86)\LilyPond\usr\bin\convert-ly.py", line 367, in main
    errors += do_one_file (f)
  File "C:\Program Files (x86)\LilyPond\usr\bin\convert-ly.py", line 320, in do_one_file
    outfile.close()
IOError: [Errno 9] Bad file descriptor

The issue may result from code near line 308-322 in convert-ly, where outfile becomes an alias for stdout. DAK suggests that convert-ly should only close files it created. The issue seems to be with Windows only.

Original discussion at http://lilypond.1069038.n5.nabble.com/convert-ly-from-the-commandline-under-windows-corrupted-td149284.html

Discussion

  • Google Importer

    Google Importer - 2013-08-20

    Originally posted by: Elu...@gmail.com

    Issue 3509 has been merged into this issue.

     
  • Google Importer

    Google Importer - 2013-08-21

    Originally posted by: dak@gnu.org

    I don't see any call of outfile.close.  In the vicinity there is
    outfile.write (result)
    but that's not anything like that.  I can't find anything like it in the remove history of convert-ly either.  This is rather puzzling.  Do we have version info for the problem?

     
  • Google Importer

    Google Importer - 2013-08-21

    Originally posted by: Elu...@gmail.com

    in the original discussion I reported about my trial to replace the flush statement -sys.stderr.flush () - with outfile.close()

     
  • Google Importer

    Google Importer - 2013-08-21

    Originally posted by: dak@gnu.org

    What happens if you just outcomment sys.stdout.flush() without any replacement?

     
  • Google Importer

    Google Importer - 2013-08-21

    Originally posted by: Elu...@gmail.com

    no error, conversions are applied but the new file is empty (and if I put some text in it it is removed)

     
  • Google Importer

    Google Importer - 2013-08-21

    Originally posted by: dak@gnu.org

    This is borked to a degree where I'd recommend getting a new version of Python.  Is this a version of Python that we deliver ourselves?

     
  • Google Importer

    Google Importer - 2013-08-21

    Originally posted by: Elu...@gmail.com

    Python 2.4.5 (#1, Mar 11 2013, 11:08:29)
    [GCC 4.1.1] on mingw32

    delivered with the Lilypond installer

     
  • Google Importer

    Google Importer - 2013-08-29

    Originally posted by: PhilEHol...@googlemail.com

    I've just installed LilyPond on my little Windows 7 netbook and can get convert-ly working with redirection without problem:

    C:\Program Files\LilyPond\usr\bin>python convert-ly.py ChangeLeftHand.ly >new.ly

    convert-ly.py (GNU LilyPond) 2.17.25

    convert-ly.py: Processing `ChangeLeftHand.ly'...
    Applying conversion: 2.17.0, 2.17.4, 2.17.5, 2.17.6, 2.17.11, 2.17.15, 2.17.18,
    2.17.19, 2.17.20, 2.17.25

    Of possible note is that I run it as 'python convertly.py'; simple typing 'convert-ly' gives "'convert-ly' is not recognized as an internal or external command,
    operable program or batch file."

    This is Windows 7 Starter.

     
  • Google Importer

    Google Importer - 2013-08-29

    Originally posted by: Elu...@gmail.com

    here (Windows 7 Home Premium) I get:

    python: can't open file 'convert-ly.py': [Errno 2] No such file or directory

    the command I use is:

    python convert-ly.py test5.ly > new.ly

    however, I'm not on C:\Program Files\LilyPond\usr\bin>, I'm on test5.ly dir

     
  • Federico Bruni

    Federico Bruni - 2018-09-12

    Everything works as expected here (Windows 7) if you use absolute path, either with bundled python (currently 2.4.5) and with my python installation (2.7.14):

    PS C:\Users\fede> python.exe 'C:\Program Files (x86)\LilyPond\usr\bin\convert-ly.py' .\Documents\convert-test.ly > hello
    .ly
    convert-ly.py (GNU LilyPond) 2.19.28
    
    convert-ly.py: Processing `.\Documents\convert-test.ly'...
    Applying conversion: 2.17.0, 2.17.4, 2.17.5, 2.17.6, 2.17.11, 2.17.14, 2.17.15, 2.17.18, 2.17.19, 2.17.20, 2.17.25, 2.17
    .27, 2.17.29, 2.17.97, 2.18.0, 2.19.2, 2.19.7, 2.19.11, 2.19.16, 2.19.22, 2.19.24, 2.19.28
    
    
    PS C:\Users\fede> cat .\hello.ly
    \version "2.19.28"
    
    {
      \tuplet 3/2 { c8 d e }
    
    }
    PS C:\Users\fede> python.exe --version
    Python 2.7.14
    PS C:\Users\fede>
    PS C:\Users\fede>
    PS C:\Users\fede>
    PS C:\Users\fede> & 'C:\Program Files (x86)\LilyPond\usr\bin\python.exe' 'C:\Program Files (x86)\LilyPond\usr\bin\conver
    t-ly.py' .\Documents\convert-test.ly > new.ly
    convert-ly.py (GNU LilyPond) 2.19.28
    
    convert-ly.py: Processing `.\Documents\convert-test.ly'...
    Applying conversion: 2.17.0, 2.17.4, 2.17.5, 2.17.6, 2.17.11, 2.17.14, 2.17.15, 2.17.18, 2.17.19, 2.17.20, 2.17.25, 2.17
    .27, 2.17.29, 2.17.97, 2.18.0, 2.19.2, 2.19.7, 2.19.11, 2.19.16, 2.19.22, 2.19.24, 2.19.28
    
    
    PS C:\Users\fede> & 'C:\Program Files (x86)\LilyPond\usr\bin\python.exe' -V
    Python 2.4.5
    PS C:\Users\fede>
    PS C:\Users\fede> cat .\new.ly
    \version "2.19.28"
    
    {
      \tuplet 3/2 { c8 d e }
    
    }
    PS C:\Users\fede>
    
     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.