Kara-Moon Forum

Developers & Technology => Musical MIDI Accompaniment (MMA) => Topic started by: Piteur on April 22, 2020, 10:15:24 PM



Title: Can't use MMA anymore (Xubuntu)
Post by: Piteur on April 22, 2020, 10:15:24 PM
Hi!

I'm completely new with MMA. I installed version 20.02 one month ago on my Xubuntu system; I tested it very quickly: writing a small file listing chords etc, generating the corresponding MIDI file, listening to it with Midi Editor.

I tried to reuse MMA today, but without success, even by submitting the old file previously used.

I have no idea what's wrong.

Description :

Last test with a very small file (name: essai00) containing this:

 Tempo 120
 Groove Rhumba
 1 F
 2 F
 3 C7
 4 F
 5 F
 6 F
 7 C7
 8 F
 9 Gm
 10 F
 11 C7
 12 F
 13 Gm
 14 F
 15 C7
 16 F /

In the terminal, I write, being of course in the folder containing the file:

   
Code:
mma essai00

Then, in the terminal, I read a very very long list of that (I only give you the end) :

  File "/usr/share/mma/MMA/parse.py", line 91, in parseFile
     parse(f)
   File "/usr/share/mma/MMA/parse.py", line 161, in parse
     simpleFuncs[action](l[1:])
   File "/usr/share/mma/MMA/parse.py", line 576, in include
     parseFile(fn)
   File "/usr/share/mma/MMA/parse.py", line 89, in parseFile
     f = MMA.file.ReadFile(n)
   File "/usr/share/mma/MMA/file.py", line 249, in __init__
     fdata.append(dataStore(lcount, l, label))
 RuntimeError: maximum recursion depth exceeded while calling a Python object


No MIDI file is generated.

Am I forgetting something?

I feel like an idiot and I apologize for that. And forgive me for asking such a basic question...  :-\

Can you give me some help, please?

Thank you very much.  :)


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: bvdp on April 22, 2020, 11:12:22 PM
No, you are not an idiot. If it doesn't work, it doesn't work and I thank you for reporting it.

Let's figure out the problem...

1. What version of python are you using? From a terminal the command:

  python --version

will tell us that.  Not that this helps you, but I just tried it with both python3 and 2 and your file works fine.

2. Can you rebuild your database. Please try:

   mma -g

and if that doesn't solve the problem:

   mma -G

you may need to be root for the -G.

You're sure you are processing the file you think you are? Try this:

3. mma essai00.mma

MMA should be finding the correct file, but ... it's worth a thought.

4. Copy the CONTENTS of the file to a new file with a unique filename (maybe something like mynewfile.mma) and try that.

5. Run MMA in various debug modes and see how far it is getting in your file. I'd start off using -e and -r. Then use -d ... anything show up?

Hope all this is getting closer the problem.


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: Piteur on April 23, 2020, 11:29:24 AM
Thank you for your answer, so quick!

I'll try to follow it up as best as I can.

No, you are not an idiot. If it doesn't work, it doesn't work and I thank you for reporting it.

Whew!

Let's figure out the problem...

1. What version of python are you using? From a terminal the command:

  python --version

will tell us that.  Not that this helps you, but I just tried it with both python3 and 2 and your file works fine.


piteur@MATERIEL-LX:~$ python --version
Python 2.7.17


2. Can you rebuild your database. Please try:

   mma -g

It doesn't work: I have the same display of the long list of errors mentioned above (last line: RuntimeError: maximum recursion depth exceeded).

and if that doesn't solve the problem:

   mma -G

you may need to be root for the -G.

Same effect!


You're sure you are processing the file you think you are? Try this:

3. mma essai00.mma

MMA should be finding the correct file, but ... it's worth a thought.

Done! Same effect!


4. Copy the CONTENTS of the file to a new file with a unique filename (maybe something like mynewfile.mma) and try that.

Done : file mynewfile.mma ; same effect!


5. Run MMA in various debug modes and see how far it is getting in your file. I'd start off using -e and -r. Then use -d ... anything show up?

I'm sorry, I didn't quite understand. I tried that:

mma -e  mynewfile.mma —> same effect
mma -r mynewfile.mma —> same effect
mma -d  mynewfile.mma —> same effect

Hope all this is getting closer the problem.

I'm very sorry, I'm afraid not.  ???

Don't you think, finally, that we should look for something on the side of Python (I've noticed many updates lately, concerning parts of Python); no doubt you know a way to test the integrity of Python…

With my sincere thanks,  :)


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: Piteur on April 23, 2020, 12:15:29 PM
Just one more thing (I didn't understand how to edit my last post, sorry):

piteur@MATERIEL-LX:~$ apt-cache policy python
python:
  Installé : 2.7.15~rc1-1

  Candidat : 2.7.15~rc1-1
 Table de version :
 *** 2.7.15~rc1-1 500
        500 http://fr.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status
piteur@MATERIEL-LX:~$ apt-cache policy python3
python3:
  Installé : 3.6.7-1~18.04

  Candidat : 3.6.7-1~18.04
 Table de version :
 *** 3.6.7-1~18.04 500
        500 http://fr.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     3.6.5-3 500
        500 http://fr.archive.ubuntu.com/ubuntu bionic/main amd64 Packages




Title: Re: Can't use MMA anymore (Xubuntu)
Post by: sciurius on April 23, 2020, 02:23:57 PM
Do you have a ~/.mmac file? If so, remove it and try again.


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: bvdp on April 23, 2020, 04:31:23 PM
Any of the rc file candidates might be an issue: mmarc (in current dir), /usr/etc/local/mmarc or /etc/mmarc.

Checking rc files is a good call since this is done before entering the -g/-G parts.

Next suggestion? Maybe resinstall mma after ensuring the current program code is purged.


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: Piteur on April 24, 2020, 10:22:20 AM
Do you have a ~/.mmac file? If so, remove it and try again.

.mmac file? I don't, according to Catfish.

Any of the rc file candidates might be an issue: mmarc (in current dir), /usr/etc/local/mmarc or /etc/mmarc.
I found /usr/local/etc/mmarc

I deleted it. So, big change. Look:

piteur@MATERIEL-LX:~/Documents/MIDI FILES$ mma ESSAI_00.mma
Warning: <Line 2> <File:ESSAI_00.mma> There appears to be an error in the
    database.   Directory '/home/bob/src/bv/mma/lib/stdlib' cannot be found.
    Please try to execute the command 'mma -G' as root.
Warning: <Line 2> <File:ESSAI_00.mma> There appears to be an error in the
    database.   Directory '/home/bob/src/bv/mma/lib/casio' cannot be found.
    Please try to execute the command 'mma -G' as root.
Warning: <Line 2> <File:ESSAI_00.mma> There appears to be an error in the
    database.   Directory '/home/bob/src/bv/mma/lib/pflib' cannot be found.
    Please try to execute the command 'mma -G' as root.
Warning: <Line 2> <File:ESSAI_00.mma> There appears to be an error in the
    database.   Directory '/home/bob/src/bv/mma/lib/kara' cannot be found.
    Please try to execute the command 'mma -G' as root.
Warning: <Line 2> <File:ESSAI_00.mma> There appears to be an error in the
    database.   Directory '/home/bob/src/bv/mma/lib/alexis' cannot be found.
    Please try to execute the command 'mma -G' as root.
Warning: <Line 2> <File:ESSAI_00.mma> There appears to be an error in the
    database.   Directory '/home/bob/src/bv/mma/lib/yamaha' cannot be found.
    Please try to execute the command 'mma -G' as root.
Error: <Line 2> <File:ESSAI_00.mma> Unable to locate library file
    '/home/bob/src/bv/mma/lib/stdlib/rhumba.mma'

So, I've done:
sudo mma -G

And mma ESSAI_00.mma results again in a file ESSAI_00.mid !!! (correct midi file, after checking)

Next suggestion? Maybe resinstall mma after ensuring the current program code is purged.

Given what I've just reported, I suppose there's no point in doing:
sudo apt-get purge mma

Thanks a lot!


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: sciurius on April 24, 2020, 11:52:07 AM
Someone should contact the packager. An initial "mma -G" (as root) must be part (last step) of the install.


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: Piteur on April 24, 2020, 12:08:11 PM
Someone should contact the packager. An initial "mma -G" (as root) must be part (last step) of the install.

Funny! Why didn't I need it a month ago, when I first installed mma?  :P (Fortunately by the way; otherwise I wouldn't have gone any further !!!)


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: bvdp on April 24, 2020, 04:38:19 PM
If you still have it, I would love to see the contents of the mmarc file you deleted was.


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: bvdp on April 25, 2020, 01:44:15 AM
I should add that I suspect that somehow someone or something modified /usr/local/etc/mmarc to make it into an endless loop. My simple proof is the simple file test.mma:

Code:
 Include test.mma

And it generates the same error as the OP initially reported. Perhaps we should have a max-include test somewhere?


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: sciurius on April 26, 2020, 08:02:25 AM
If that would open the possibility to show what files are included and die gracefully, yes that would be nice.

OTOH mma -o test.mma already clearly shows the includes flying by.


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: bvdp on April 26, 2020, 04:09:29 PM
Python limits recursion to about 1000 iterations. So, for the OP, there were just shy of this open() calls.

I think we should limit the number of open files to about 50. And, if an attempt is made to open more than that an error message including the last file name will be printed. Any other comments on this?


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: bvdp on April 26, 2020, 06:18:43 PM
I think the attached patch will solve the recursion problem. If just tracks the number of levels in parseFile().


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: sciurius on April 26, 2020, 06:28:12 PM
The parseStack counter looks okay (I assume you've tested it).

But the second part of the patch, adding includeCount and not using it?


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: bvdp on April 27, 2020, 04:15:27 PM
I think that is safe to ignore ... no idea why it showed up. I'm actually making a minor change to the code right now to make it a tad cleaner ... and, yes, I have tested it all and it seems to work with py2 and 3.


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: bvdp on April 27, 2020, 09:00:12 PM
This accomplishes the same task, but I think it's a bit nicer way to do it.


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: sciurius on April 28, 2020, 06:30:57 AM
Ugly hack just to save a global variable?


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: bvdp on April 28, 2020, 04:30:17 PM
Well, not exactly a "hack". It's perfectly valid python ... and like they say: One man's ugly is another man's elegance :)

Actually, there is another way to do this...

def myfunc():
   if not 'depth' in myfunc.__dict__:
        myfunc.depth = 0

     myfunc.depth += 1
     if myfunc.depth >50:
          ... test level < 50 and report/error
     ... do stuff
     myfunc.depth -= 1

But, I think that is really ugly :)


Title: Re: Can't use MMA anymore (Xubuntu)
Post by: Piteur on May 01, 2020, 03:31:19 PM
If you still have it, I would love to see the contents of the mmarc file you deleted was.
Sorry, it's deleted…