Errors with midi2ly and musicxml2ly

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Errors with midi2ly and musicxml2ly

Артем Тартаковский
I've tried to convert a MIDI file into LilyPond (version 2-19.83-1) using
the command prompt, but it gives me an error:

  File "C:\Program Files (x86)\LilyPond\usr\bin\midi2ly.py", line 545
    sys.stderr.write ("SKIP: %s\n" % `e`)
                                     ^
SyntaxError: invalid syntax

What's the problem with the code?

Artem
_______________________________________________
bug-lilypond mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-lilypond
Reply | Threaded
Open this post in threaded view
|

Re: Errors with midi2ly and musicxml2ly

Aaron Hill
On 2019-11-19 3:29 pm, Артем Тартаковский wrote:

> I've tried to convert a MIDI file into LilyPond (version 2-19.83-1)
> using
> the command prompt, but it gives me an error:
>
>   File "C:\Program Files (x86)\LilyPond\usr\bin\midi2ly.py", line 545
>     sys.stderr.write ("SKIP: %s\n" % `e`)
>                                      ^
> SyntaxError: invalid syntax
>
> What's the problem with the code?

It's a compatibility issue between Python 2 and 3.  The backtick
operator was removed [1] in Python 3, in favor of the repr() procedure.

[1]: https://portingguide.readthedocs.io/en/latest/syntax.html#backticks

It is my understanding the scripts shipping with LilyPond are not
expected to be interpretable by Python 3 yet.


-- Aaron Hill

_______________________________________________
bug-lilypond mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-lilypond
Reply | Threaded
Open this post in threaded view
|

Re: Errors with midi2ly and musicxml2ly

Aaron Hill
On 2019-11-20 12:00 am, Артем Тартаковский wrote:

> ср, 20 нояб. 2019 г., 2:00 Aaron Hill <[hidden email]>:
>> It's a compatibility issue between Python 2 and 3.  The backtick
>> operator was removed [1] in Python 3, in favor of the repr()
>> procedure.
>>
>> [1]:
>> https://portingguide.readthedocs.io/en/latest/syntax.html#backticks
>>
>> It is my understanding the scripts shipping with LilyPond are not
>> expected to be interpretable by Python 3 yet.
>
> So what do I have to replace this construction with?

Near as I can tell, it's a simple replacement of `foo` with repr(foo).  
So, you could potentially run the scripts through the following sed
command:

   sed -i~ 's/`\([^`]*\)`/repr(\1)/g' *.py


-- Aaron Hill

_______________________________________________
bug-lilypond mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-lilypond
Reply | Threaded
Open this post in threaded view
|

Re: Errors with midi2ly and musicxml2ly

m.tarenskeen
   Verzonden vanaf mijn Huawei mobiele telefoon

   -------- Oorspronkelijk bericht --------
   Onderwerp: Re: Errors with midi2ly and musicxml2ly
   Van: [hidden email]
   Aan: Aaron Hill
   Cc:

     There are more python2 vs python3 issues in those scripts than just
     that one. You can try to check ( and fix) using the 2to3 script.
     Or use Python2 to run the scripts.
     Verzonden vanaf mijn Huawei mobiele telefoon

   -------- Oorspronkelijk bericht --------
   Onderwerp: Re: Errors with midi2ly and musicxml2ly
   Van: Aaron Hill
   Aan: [hidden email]
   Cc:

     On 2019-11-20 12:00 am, Артем Тартаковский wrote:
     > ср, 20 нояб. 2019 г., 2:00 Aaron Hill :
     >> It's a compatibility issue between Python 2 and 3. The backtick
     >> operator was removed [1] in Python 3, in favor of the repr()
     >> procedure.
     >>
     >> [1]:
     >>
     https://portingguide.readthedocs.io/en/latest/syntax.html#backticks
     >>
     >> It is my understanding the scripts shipping with LilyPond are not
     >> expected to be interpretable by Python 3 yet.
     >
     > So what do I have to replace this construction with?
     Near as I can tell, it's a simple replacement of `foo` with
     repr(foo).
     So, you could potentially run the scripts through the following sed
     command:
     sed -i~ 's/`\([^`]*\)`/repr(\1)/g' *.py
     -- Aaron Hill
     _______________________________________________
     bug-lilypond mailing list
     [hidden email]
     https://lists.gnu.org/mailman/listinfo/bug-lilypond
_______________________________________________
bug-lilypond mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-lilypond
Reply | Threaded
Open this post in threaded view
|

Re: Errors with midi2ly and musicxml2ly

Aaron Hill
In reply to this post by Aaron Hill
On 2019-11-20 9:40 am, [hidden email] wrote:
> There are more python2 vs python3 issues in those scripts than just
> that one. You can try to check ( and fix) using the 2to3 script.

Fair point.  I was only intending to address Артем's question on that
specific bit of syntax.

> Or use Python2 to run the scripts.

That is probably the best advice, until such time as folks get around to
fully addressing all of the porting/compatibility issues.


-- Aaron Hill

_______________________________________________
bug-lilypond mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-lilypond
Reply | Threaded
Open this post in threaded view
|

Re: Errors with midi2ly and musicxml2ly

Aaron Hill
========================================================================
A quick reminder for everyone to please keep all replies on the relevant
mailing lists.

Unless the topic is clearly a sensitive matter or someone has expressly
requested private communication, always reply to the mailing list and
not the individual.  This practice ensures the entire context for the
topic of discussion is visible to the wider audience and is archivable
for future reference.
========================================================================


On 2019-11-20 12:05 pm, Артем Тартаковский wrote:

> ср, 20 нояб. 2019 г. в 20:18, Aaron Hill <[hidden email]>:
>> On 2019-11-20 9:40 am, [hidden email] wrote:
>> > There are more python2 vs python3 issues in those scripts than just
>> > that one. You can try to check ( and fix) using the 2to3 script.
>>
>> Fair point.  I was only intending to address Артем's question on that
>> specific bit of syntax.
>>
>> > Or use Python2 to run the scripts.
>>
>> That is probably the best advice, until such time as folks get around
>> to
>> fully addressing all of the porting/compatibility issues.
>
> How can I do this in command prompt (or somewhere else)?

You will have to look up instructions specific to your operating system
for installing and using Python 2 and Python 3 side-by-side.

And I cannot comment at all regarding the 2to3 script mentioned.


On 2019-11-20 12:57 pm, Артем Тартаковский wrote:
> There is another problem with musicxml2ly. It gives me an error:
> Traceback (most recent call last):
>   File "musicxml2ly.py", line 3297, in ?
>     main()
>   File "musicxml2ly.py", line 3279, in main
>     basefilename = args[0].decode('utf-8')
>   File "/usr/lib/python2.4/encodings/utf_8.py", line 16, in decode
> UnicodeDecodeError: 'utf8' codec can't decode bytes in position 35-36:
> invalid data

I am afraid my knowledge of Python is limited to only what I can find
via web searches.  I do not use Python in my day-to-day work, so
hopefully there are others on the list that can offer more insightful
guidance.


-- Aaron Hill

_______________________________________________
bug-lilypond mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-lilypond
Reply | Threaded
Open this post in threaded view
|

Re: Errors with midi2ly and musicxml2ly

Aaron Hill
Forwarding for visibility...

> On 2019-11-20 12:57 pm, Артем Тартаковский wrote:
>> There is another problem with musicxml2ly. It gives me an error:
>> Traceback (most recent call last):
>>   File "musicxml2ly.py", line 3297, in ?
>>     main()
>>   File "musicxml2ly.py", line 3279, in main
>>     basefilename = args[0].decode('utf-8')
>>   File "/usr/lib/python2.4/encodings/utf_8.py", line 16, in decode
>> UnicodeDecodeError: 'utf8' codec can't decode bytes in position 35-36:
>> invalid data

On 2019-11-20 1:09 pm, Артем Тартаковский wrote:

> I fixed this problem, and it converts the musicxml2ly file, though no
> notes
> are printed. The command prompt prints the next thing:
> musicxml2ly.py: Reading MusicXML from
> C:\Users\User\Downloads\We_Will_Stand_for_Everfree.musicxml ...
> musicxml2ly.py: Converting to LilyPond expressions...
> musicxml2ly.py: Converting to LilyPond expressions...
> musicxml2ly.py: Converting to LilyPond expressions...
> musicxml2ly.py: Output to `We_Will_Stand_for_Everfree.ly'
> musicxml2ly.py: Converting to current version () notations ...
> Системе не удается найти указанный путь.
> Why does the system fail to find the path given?

_______________________________________________
bug-lilypond mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-lilypond
Reply | Threaded
Open this post in threaded view
|

Re: Errors with midi2ly and musicxml2ly

Noeck
In reply to this post by Aaron Hill
Hi,

Am 20.11.19 um 01:00 schrieb Aaron Hill:
> "SKIP: %s\n" % `e`

2to3 is the way to go as others said before. In this particular case,
rather than calling repr, the standard solution would be:

"SKIP: %r\n" % e

as %r uses the repr-form while %s the str-form.

Cheers,
Joram

_______________________________________________
bug-lilypond mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-lilypond