Generic IOM Access Pattern

Posted on
Wed Nov 07, 2018 9:04 pm
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

Generic IOM Access Pattern

Use Case: flexible- run indigo IOM commands from iPhone
Requirements: Shortcuts, SSH server enabled

Image

Posted on
Sun Nov 11, 2018 1:50 pm
anyone offline
User avatar
Posts: 125
Joined: Apr 03, 2011
Location: Norfolk, VA

Re: Generic IOM Access Pattern

Is it possible to pass an argument to a script in a similar manner?

i.e. something like:

"/Library/Application Support/Perceptive Automation/Indigo 7.2/IndigoPluginHost.app/Contents/MacOS/IndigoPluginHost" -x ' /SomeFolder/indigo_script.py "dictated text"

Posted on
Sun Nov 11, 2018 3:55 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Generic IOM Access Pattern

Yeah, you almost had it:

Code: Select all
'/Library/Application Support/Perceptive Automation/Indigo 7.2/IndigoPluginHost.app/Contents/MacOS/IndigoPluginHost' -x /SomeFolder/indigo_script.py "dictated text"

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Nov 12, 2018 9:39 am
anyone offline
User avatar
Posts: 125
Joined: Apr 03, 2011
Location: Norfolk, VA

Re: Generic IOM Access Pattern

Thanks Jay, it felt like I was close.

I'm still stuck though. How would I access the argument within the python program? Below is the error I received when attempting to retrieve it with the "sys.argv" command. Should I import something other than sys to do that?

Code: Select all
Nov 12, 2018 9:59:51 AM
   Script Error                    indigo-example.py: 'module' object has no attribute 'argv'
   Script Error                    Exception Traceback (most recent call shown last):

     indigo-example.py, line 14, at top level
     indigo-example.py, line 8, in main
AttributeError: 'module' object has no attribute 'argv'

Posted on
Mon Nov 12, 2018 11:01 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Generic IOM Access Pattern

anyone wrote:
Thanks Jay, it felt like I was close.

I'm still stuck though. How would I access the argument within the python program? Below is the error I received when attempting to retrieve it with the "sys.argv" command. Should I import something other than sys to do that?

Code: Select all
Nov 12, 2018 9:59:51 AM
   Script Error                    indigo-example.py: 'module' object has no attribute 'argv'
   Script Error                    Exception Traceback (most recent call shown last):

     indigo-example.py, line 14, at top level
     indigo-example.py, line 8, in main
AttributeError: 'module' object has no attribute 'argv'


Post the actual code you're using. Guessing doesn't help anyone.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Nov 12, 2018 1:51 pm
anyone offline
User avatar
Posts: 125
Joined: Apr 03, 2011
Location: Norfolk, VA

Re: Generic IOM Access Pattern

The problem seems deeper than my code. I'm just trying to prove I can pass something.

Code: Select all
#!/usr/bin/env python

import sys

def main():
   
    words = " ".join(sys.argv)   
    indigo.server.log(words)

if __name__ == "__main__":
    main()

Posted on
Mon Nov 12, 2018 6:28 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Generic IOM Access Pattern

Yeah, that's not gonna work. When specified that way, the args after the script name are just dropped by the IPH process (sorry, I had forgotten this).

We've got a built-in solution coming with 7.3. Basically, you write a wrapper script around an IPH call that accepts the parameters then creates a Indigo Python script that IPH executes and it passes the parameters to a specified method in a shared Indigo Python script. It's a little complicated to get right, but our built-in solution will be pretty easy.

You build a shared Indigo Python script like the one specified in the Scripting Tutorial.

When Indigo 7.3 ships, you execute this:

Code: Select all
/usr/local/indigo/indigohost -m indigo_attachments. log "Here is the message"


Which will call the log method in the indigo_attachments.py file example in the above link via a script that we construct. The shell script is this:

Code: Select all
from {path} import {method}
return {method}({args})


I insert the module in for path (indigo_attachments) and the method name for method (log) and the args as a string of the args. I then pass that script to the IPH process to run.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest