Addon.xml for service/script
#1
Hi,

After reading through the wiki section regarding this([url]http://kodi.wiki/view/Addon.xml#.3Cprovides.3E_element[/url),,
it would seem that the 'provides executable; tag within 'extension' is supposed to indicate whether or not the addon is listed under programs.

My addon is a service, however to implement other features, I also call it from the settings page with arguments.
I order to avoid the 'Warning: Script invoked without an addon. Adding all addon modules installed to python path as fallback. This behaviour will be removed in future version.'
I add a second extension point as a python script:

Code:
<extension point="xbmc.service" library="default.py" start="startup">
</extension>
<extension point="xbmc.python.script" library="default.py">
</extension>

However, adding that second point, even without including a 'provides executable' tag seems to cause it to be listed under Programs, for which there is no need.
Furthermore invoking it from there by clicking on it triggers an abort event and the service addon shuts down.

Is there a way to keep it from being listed or at least a way of detecting that the abort was called because the user invoked the addon from the Programs menu so it doesn't silently abort?

Thanks,
Ken
Reply
#2
Forget about the warning unless your script indeed uses additional libraries in addition to the standard library and xbmc* modules. And IMO it's better to have separate scripts that perform different tasks, like a background service and commands invoked on demand.
Reply
#3
If I separate it out, I need the requests module for one of the commands invoked. Which at least for now I guess is ok since it loads all modules?

I'm wondering if I should start a bug report on kodi.trac.tv about the fact that it aborts the script...

I'm hoping that one of the Kodi team members might chime in about this behavior and their view of the proper way to implement this.

EDIT: So what seems to happen is if the code is running and you click on the entry in Programs, the code releases from monitor.waitForAbort(), and fires the monitor.onAbortRequested() event so the code just exits if you are keeping it running using waitForAbort.

The second time you click on it's entry it runs again.
Reply
#4
I'm not entirely sure what you're trying to do, but you could use a different library file for the different extension point, if that helps.

I did that on my service, see here: https://github.com/elParaguayo/service.b...xml#L13-15
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#5
Yes, I sure can move the code to a different file. I'm posting about it for two reasons:

1) According to the wiki, the 'provides' tag is what is used to decide where it appears in the gui. I wouldn't expect the script to be listed in Programs without 'provides executable'. And for this type of functionality, even if I offload that code to a different module, I wouldn't want it listed in programs anyway because none of the functionality would work without an argument..
2) It was unexpected, at least for me, that clicking on the entry in Programs would trigger an abort event in an already running script. If it's in the wiki already, please point that out to me. If not, I will add it.

EDIT:
I found that the abort request is forced by the system. Attempting to not abort resulted in the system attempting to kill it and eventually caused Kodi to hang (on windows at least).
"ERROR: CPythonInvoker(9, C:\Users\Ken User\AppData\Roaming\Kodi\addons\script.service.abortdemo\default.py): script didn't stop in 5 seconds - let's kill it"
Code:
import xbmc

class RunMonitor(xbmc.Monitor):
    def __init__(self):
        super(RunMonitor, self).__init__()
        self.system_aborting = False

    def onAbortRequested(self):
        xbmc.log('########### onAbortrequested for abort demo')

    def onNotification(self, sender, method, data):
        if method == 'System.OnQuit' or method == 'System.OnRestart':
            xbmc.log('######## System Aborting')
            self.system_aborting = True

monitor = RunMonitor()
xbmc.log('######### Abort demo started')
# monitor.waitForAbort()
while monitor.system_aborting is False:
    xbmc.sleep(250)
xbmc.log('########### Abort demo - passed from abort loop')
xbmc.sleep(3000)
xbmc.log('########### Exiting abort demo'))
Reply
#6
1. 'provides' have always been for plugins only and you use it when you want to create a plugins that provides executables, ie. to list directories with 'programs'. 'script' is for when you want something that behaves as a standalone executable visible in programs menu.
2. Your two extensions are the same script, which is probably why it sees an already running instance and tries to stop it when you open the plugin. Use different ones. Scripts and services have completely different uses so it make no sense that these should have the same main script anyway..
Reply
#7
(2016-04-12, 11:50)takoi Wrote: 1. 'provides' have always been for plugins only and you use it when you want to create a plugins that provides executables, ie. to list directories with 'programs'. 'script' is for when you want something that behaves as a standalone executable visible in programs menu.
2. Your two extensions are the same script, which is probably why it sees an already running instance and tries to stop it when you open the plugin. Use different ones. Scripts and services have completely different uses so it make no sense that these should have the same main script anyway..

OK, however even when I move the code to a separate module, it still appears in 'Programs' and does nothing since when I call it from 'Settings' it requires parameters to do anything useful. Is there a way to prevent it from appearing under Programs?
Reply
#8
(2016-04-12, 12:35)KenV99 Wrote: OK, however even when I move the code to a separate module, it still appears in 'Programs' and does nothing since when I call it from 'Settings' it requires parameters to do anything useful. Is there a way to prevent it from appearing under Programs?
Use xbmc.python.library instead of script
Reply
#9
(2016-04-12, 21:41)takoi Wrote:
(2016-04-12, 12:35)KenV99 Wrote: OK, however even when I move the code to a separate module, it still appears in 'Programs' and does nothing since when I call it from 'Settings' it requires parameters to do anything useful. Is there a way to prevent it from appearing under Programs?
Use xbmc.python.library instead of script

Thanks, that was what I was looking for.
Reply

Logout Mark Read Team Forum Stats Members Help
Addon.xml for service/script0