My usual workflow with mayapy has been to just write a script that is designed to be called with mayapy.exe. This works fine when that is the intention from the start, however now I would like to run functions from existing libraries/modules using mayapy and I am not quite sure how to proceed. If I go the write-a-script route then I will end up creating a lot of scripts just to run existing functions in a way that I can pass them arguments via the command line. My other thought was to create a script that accepts a module name, function name, and all the arguments to pass. While that would work I figure there may be a better way.
How do you guys handle situations like this? Is this a good case for RPC?
Also, the mayapy instances that would be running these scripts will be on artists’ machines, and will be created (and killed) for each script that gets run. I’m not trying to set up persistent mayapy sessions (at the moment).
That’s what I figured. I’ll got the RPC route, thanks.
EDIT:
If I’m running this on machines that are connected to the internet, do I need to secure the connection? I haven’t done any networking in python so I’m not to what extent I need to protect my connections. The server and client will be on the same machines, if that matters.
we have a Batch Utility GUI that has a text input field. I can type in a series of python commands to run, imports, run functions, etc. That text is captured and sent to the mayapy process that then executes the python code on each file.
I’ve been experimenting with rpyc and enjoying the simplicity of it. I’m not sure what to do about security and have been finding it difficult to find good beginner resources on it. Do you have any pointers or suggestions on good practices/approaches for securing an rpc connection? Basic HTTP auth? SSL?
RPYC will let you expose services on a case-by-case basis (instead of using ‘classic mode’ where the remote client is effectively running the local host as if it were local. Services — RPyC I have never bothered with security beyond that because my use-cases are all in house. But that’s better than nothing. In a ‘real’ environment you’d want to have a separate authentication service, maybe using OAuth2. That basically means you have send a request to a separate server which returns a token and then that token is the guarantee of what rights the user has. It’s not trivial to do, alas. Here’s an example of using OAuth to get to twitter:
Can I not just restrict my service to connections from localhost and not worry about authenticating? I only need to communicate with an instance on the same machine.