2012-09-26, 23:36
Although I've been programming JavaScript and C-style languages for years, this is my first foray into Python (which I'm really liking so far), so please forgive me if my questions have obvious answers.
I'm simply trying to run a function when I exit a plugin. I have code such as this:
And this is all working fine. However, I can't find a way to run a function when the plugin exits. I wondered if there might be a route such as which would take me to the 'parent' folder, but there doesn't seem to be.
I've also tried putting a 'try / finally' around the 'plugin.run()' code but the 'finally' code gets called immediately. I've explored 'atexit' too but realise that won't work either.
I've come across some posts about an Action Handler but I can't find any examples sufficiently complete to guide me.
Any thoughts / tips would be much appreciated.
(The background to this: I'm trying to get a VPN to exit when I leave the Add-on... I plan to use 'os.startfile' to kick off an external script).
I'm simply trying to run a function when I exit a plugin. I have code such as this:
Code:
@plugin.route('/')
def view_top():
addDirectoryItem(plugin.handle, plugin.url_for("/funstuff"), ListItem("Do Fun Stuff"), True)
endOfDirectory(plugin.handle)
@plugin.route('/funstuff')
def funstuff():
doFunStuff()
if ( __name__ == "__main__" ):
plugin.run()
And this is all working fine. However, I can't find a way to run a function when the plugin exits. I wondered if there might be a route such as
Code:
@plugin.route('../')
I've also tried putting a 'try / finally' around the 'plugin.run()' code but the 'finally' code gets called immediately. I've explored 'atexit' too but realise that won't work either.
I've come across some posts about an Action Handler but I can't find any examples sufficiently complete to guide me.
Any thoughts / tips would be much appreciated.
(The background to this: I'm trying to get a VPN to exit when I leave the Add-on... I plan to use 'os.startfile' to kick off an external script).