Forums > MaxMSP

Jython, execute a py script with arguments


Jun 20 2013 | 5:47 pm

Hi,

I have a py script, that I can execute from the command line like so:

> py myscript.py ip_address port
e.g. py 127.0.0.1 8080

I really cant understand in the net.loadbang.jython where to put the "py" script and how to call it with arguments in a max patch. Would really appreciate some direction on using what seems to be a great tool. Call a script from a "py" file doesnt seem to be covered in the jython.BasicUsage.mxt

Cheers
N

Jun 20 2013 | 11:53 pm

ok calling a script is covered in the mxt. However, im still confused on how to add args to the execution.

Im trying this and its not working:

mxj net.loadbang.jython.mxj.ScriptEngine @args ip_address port

Jun 21 2013 | 8:44 am

ne1?

Jun 23 2013 | 4:02 am

You can get the arguments from @args by calling maxObject.getArgs() (which returns an Atom[]). This isn’t the same as command-line arguments to a script (although I suppose that could be mocked) so you’d have to modify the script, or load it from an enclosing script which sets the arguments up.

Aug 13 2013 | 6:21 pm

Thanks Nick, This was really helpful for me. Finally got jython up and running and its working really well.

I notice you have implemented some lemur template loading in your clojure software. Ive been trying to use Jython with the script https://github.com/cassiel/sifaka/blob/master/example-code/stanton/lemur_loader.py

It works (as in loading templates). However, I run into some problems when loading into a specific container. I can load one jzlib into a container, but when I destroy the contents of the container and load another jzlib, the ipad app crashes the springboard. It seems to have something to do with the lemur app closing the connection half way through loading a template.

Id be really grateful to find out if you had any similar issues in your implementation and whether/how you overcame these.

Cheers

N

Aug 15 2013 | 4:03 am

The lemur_loader.py is someone else’s code that I used as a source reference; I don’t know offhand how well it works. Certainly, the Clojure-based loader works passably; it crashes the Lemur app occasionally, but is usable.

Oct 08 2015 | 6:22 pm

@NEWTFISH I’m digging to find a way to load JZML patch from Max to lemur . How did you manage to get loading template to work with net.loadbang.jython and lemur_loader.py .
thanks

Viewing 7 posts - 1 through 7 (of 7 total)

Forums > MaxMSP