external py script calling plugin methods

Posted on
Wed Nov 05, 2014 9:50 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

external py script calling plugin methods

i would like to be able to execute an external python file that must have access to indigo methods i.e. access to the calling plugin python code.

when I spawn a external shell with
subprocess.Popen( "/usr/bin/python2.6 ‘“+pathToPyFile/pythonfile.py ", shell=True……)
it is an independent process that does not know anything of indigo or the calling plugin.

Here is what I like to accomplish:

start an action like:
plug = indigo.server.getPlugin("com.karlwachs.INDIGOplotD")
if not plug.isEnabled(): return
plug.executeAction("showDeviceStates" , props ={"deviceOrVariable": ‘abcdefxyz’})

where the command etc are supplied by the external python code..

An alternative would be to create an action python script and execute the action.
BUT in the current INDIGO version creating an action is not supported from python.

Just a thought... could I use eval() to "evaluate" the code?

thx

Karl

Posted on
Wed Nov 05, 2014 10:57 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: external py script calling plugin methods

Can you not just execute the script as an external Python script? I guess I'm unclear why it has to be a separate process.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Nov 05, 2014 11:11 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: external py script calling plugin methods

Tried exec(). That works


Sent from my iPhone using Tapatalk

Posted on
Wed Nov 05, 2014 11:24 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: external py script calling plugin methods

I am storing the configuration of the plugin as action commands in a py file each day. Executing the py file in an action group server action will restore the configuration of the plugin. Instead of copy and paste I like to pick the file from a menu and let the plugin execute the plugin.actions stored in the py file itself


Sent from my iPhone using Tapatalk

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests

cron