path to plugin changes while being disabled

Posted on
Wed Sep 02, 2015 10:30 am
kw123 offline
User avatar
Posts: 8392
Joined: May 12, 2013
Location: Dallas, TX

path to plugin changes while being disabled

Just in case when you come across this.
Here the use-case:
when you disable a plugin and would like to execute an external program (e.g. python) that is included in your plugin package as the last step

When you disable a plugin INDIGO immediately moves the plugin to the /Plugin (Disabled)/ directory. This happens before the exit exception gets handled.
so if you would like to start an e.g. cleanup up job at the point of exit you must choose the path to the /Plugin (Disabled)/ directory:
Code: Select all
      try:
      
         while True:
                    your code here
      except  Exception, e:
            indigo.server.log( u"in Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e) )
      
      subprocess.Popen("/usr/bin/python2.7   '/Library/Application Support/Perceptive Automation/Indigo 6/Plugins (Disabled)/yourPluginName.indigoPlugin/Contents/Server Plugin/progamToLauch.py'", shell = True)
instead of
Code: Select all
subprocess.Popen("/usr/bin/python2.7   '/Library/Application Support/Perceptive Automation/Indigo 6/Plugins/yourPluginName.indigoPlugin/Contents/Server Plugin/progamToLauch.py'", shell = True)

This is not true when you "restart" a plugin

Took me some time to figure this out.


Karl

Posted on
Wed Sep 02, 2015 10:56 am
matt (support) offline
Site Admin
User avatar
Posts: 21429
Joined: Jan 27, 2003
Location: Texas

Re: path to plugin changes while being disabled

Thanks for the info and workaround.

Image

Posted on
Wed Sep 02, 2015 12:13 pm
RogueProeliator offline
User avatar
Posts: 2506
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: path to plugin changes while being disabled

Just a hint, but you may not want to hard code a path in there for the main installation path... you can get the primary install path, if I am not mistaken, with a call:
Code: Select all
basePath = indigo.server.getInstallFolderPath()
and then add in your plugin directory (enabled or disabled) from there.

Adam

Posted on
Wed Sep 02, 2015 3:55 pm
kw123 offline
User avatar
Posts: 8392
Joined: May 12, 2013
Location: Dallas, TX

Re: path to plugin changes while being disabled

Code: Select all
   def getIndigoPath(self):
      found=False
      indigoVersion = 0
      for indi in range(3,100):  # we are optimistic for the future of indigo, starting with V3
         if found:
            if os.path.isdir("/Library/Application Support/Perceptive Automation/Indigo "+str(indi)): continue
            else:
               indigoVersion = indi-1
               break
         else:
            if os.path.isdir("/Library/Application Support/Perceptive Automation/Indigo "+str(indi)): found = True

      self.indigoPath   =   "/Library/Application Support/Perceptive Automation/Indigo "+str(indigoVersion)+"/"


I still use this one, no prerequisite for any version level..

Karl

Posted on
Wed Sep 02, 2015 10:17 pm
RogueProeliator offline
User avatar
Posts: 2506
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: path to plugin changes while being disabled

I still use this one, no prerequisite for any version level..

I used to do something similar but stopped because if a user has two installations in place -- such as installing a new version, testing a new version before taking the plunge, etc. then you don't know which the user is currently running.

We want people to upgrade and support Indigo anyway - push that API limit! :-)

Adam

Posted on
Wed Sep 02, 2015 10:48 pm
kw123 offline
User avatar
Posts: 8392
Joined: May 12, 2013
Location: Dallas, TX

Re: path to plugin changes while being disabled

old habits die hard :roll:

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests