autolog wrote:If the plugin has the method deviceDeleted it must either call deviceStopComm (if the plugin has the method) or do a super(Plugin, self).deviceDeleted(dev) at the end of the method.
Correct.
autolog wrote:Is there anyway in the deviceStopComm method to tell whether a device has been deleted or just disabled?
Not in the base implementation, but you can add that functionality via your own implementation of
deviceDeleted if you use an additional named argument (with default value) on your
deviceStopComm implementation. In this case you wouldn't call the super() implementation, which I'm not sure I totally recommend because it is possible we could additional logic to the base implementation of deviceDeleted your implementation wouldn't have. Currently though it doesn't do much:
- Code: Select all
def deviceDeleted(self, dev):
if dev.pluginId != self.pluginId:
return # device is not plugin based -- bail out
if dev.configured and dev.enabled:
self.deviceStopComm(dev)
autolog wrote:Also at what point does the dev get actually deleted - is it after both of these methods end?
I think is probably indeterministic. While when the server initially starts broadcasting to the plugins the device is deleted it probably still exists in the database, it doesn't wait for the plugins to process the callback hooks to continue on with its logic (which will delete the device). So it might be possible that the device is still in indigo.devices dict, I wouldn't count on it. Probably by the time a plugin requested it from the Indigo Server it will be gone.
You may already know this, but you can see the base (super()) implementation of these methods in the file:
/Library/Application Support/Perceptive Automation/Indigo 7.x/IndigoPluginHost.app/Contents/Resources/PlugIns/plugin_base.py