Reload, enable, disable plugin via trigger action / script?

Forum rules

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo

Posted on
Sun Dec 25, 2011 8:55 am
BillC offline
Posts: 237
Joined: Mar 09, 2008

Reload, enable, disable plugin via trigger action / script?

How would one enable/disable/reload a plugin via a trigger action / embedded script? I can't seem to find any applescript or python equivalent to the menu items Plugins---->(specific plugin)---->[enable][disable][reload], nor are those commands available as actions.

Posted on
Sun Dec 25, 2011 10:07 am
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: Reload, enable, disable plugin via trigger action / scri

Try Menu scripting.

Posted on
Sun Dec 25, 2011 10:37 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Reload, enable, disable plugin via trigger action / scri

You can, via an embedded Indigo python script, restart a plugin if (and only if) it is already enabled:

Code: Select all
plugin = indigo.server.getPlugin("com.perceptiveautomation.indigoplugin.easydaq-usb-relay-cards")
if plugin.isEnabled():
   plugin.restart()

Image

Posted on
Tue Jan 10, 2012 12:24 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Reload, enable, disable plugin via trigger action / scri

support wrote:
You can, via an embedded Indigo python script, restart a plugin if (and only if) it is already enabled:
Code: Select all
plugin = indigo.server.getPlugin("com.perceptiveautomation.indigoplugin.easydaq-usb-relay-cards")
if plugin.isEnabled():
   plugin.restart()
So, is there any reason that a plugin could/should not cause it self to reload by invoking the restart method on itself? This would be desirable in a case where a configuration change has been made that requires a plugin restart.

Posted on
Tue Jan 10, 2012 7:49 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Reload, enable, disable plugin via trigger action / scri

Hmmm... good question. I don't think it will be ideal. The restart call is going to block until Indigo Server has finished stopping/starting the plugin, but it won't be able to stop it while it is blocked, which will result in the Indigo Server force killing it. I could probably add an optional doNotBlock parameter to the restart method that would make it cleaner...

Image

Posted on
Tue Jan 10, 2012 7:57 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Reload, enable, disable plugin via trigger action / scri

In the next release (5.0.3, not yet available), try passing in a waitUntilDone argument of False and I think it will work smoothly:

Code: Select all
plugin.restart(waitUntilDone=False)

Image

Posted on
Tue Jan 10, 2012 10:44 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Reload, enable, disable plugin via trigger action / scri

Great! That will be a nice help - its always better to have the software do something when it can instead of relying on the user to perform some required task.

Looking forward to 5.0.3

Posted on
Tue Jan 10, 2012 10:51 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Reload, enable, disable plugin via trigger action / scri

Just curious - what configuration change would require the plugin to restart rather than the plugin logic just adjust to the new change?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jan 10, 2012 11:02 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Reload, enable, disable plugin via trigger action / scri

In the ad2usb plugin users can change between USB and serial connectivity and between two modes of operation: basic and advanced (with different internal data structures). I currently support closedPrefsConfigUi() and try to do the right thing. It works generally, but still, in both cases, I have reports of error messages thrown. This happens in some installations and not others.

Given a rich test lab (OS version, ad2usb board/firmware version, and panel model), I could probably engineer around all possibilities. But, a restart is clean and avoids the chance of error.

Posted on
Tue Jan 10, 2012 11:17 am
terrydew offline
Posts: 258
Joined: Jun 10, 2011

Re: Reload, enable, disable plugin via trigger action / scri

I copied you code into an action group and it worked restarting the easydaq plugin. However when I replaced easydaq with another plugin nothing happened? Does a plugin have to allow this or some other feature to work. It is enabled and I checked the syntax and have tried on a couple of plugins.

I must be doing something wrong when I replace the plugin name (am getting from plugin file name). I have never used an embedded Indigo python script before so maybe I am missing a step? If I change the plugin name do I have to compile or something else.

I have a feeling I am going to feel very dumb when I find the problem but for now I am stumped

Posted on
Tue Jan 10, 2012 11:34 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Reload, enable, disable plugin via trigger action / scri

You have to get the right plugin object first - to get the plugin instance you have to use the plugin's complete ID. It should be specified in the plugin's documentation, but it can be found inside the Info.plist inside the plugin bundle.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jan 10, 2012 12:08 pm
terrydew offline
Posts: 258
Joined: Jun 10, 2011

Re: Reload, enable, disable plugin via trigger action / scri

Thanks Jay

That did it (after I figured out you had to replace from the " and not just the name :D )

Indigo really is a super app!!!

Terry

Posted on
Tue Jan 31, 2012 9:34 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Reload, enable, disable plugin via trigger action / scri

I guess self.restart(waitUntilDone=False) didn't make it into 5.0.3 :cry:

Jan 31, 2012 19:25:07
Starting Indigo Server version 5.0.3
... ...
<type 'exceptions.TypeError'>: restart() got an unexpected keyword argument 'waitUntilDone'

Posted on
Tue Jan 31, 2012 10:25 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Reload, enable, disable plugin via trigger action / scri

Instead of calling restart() on self, try getting the plugin via:

Code: Select all
plugin = indigo.server.getPlugin("some.plugin.id.here")

And then plugin.restart() should take the new argument.

Image

Posted on
Wed Feb 01, 2012 12:15 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Reload, enable, disable plugin via trigger action / scri

support wrote:
... try
plugin = indigo.server.getPlugin("some.plugin.id.here")
And then plugin.restart() should take the new argument.


Yup. That worked. Thanks!!

Who is online

Users browsing this forum: No registered users and 1 guest