Posts: 2,336
Joined: Sep 2006
Reputation:
311
Hi,
Basically, I have a service script that I need to detect if it's running or not.
Therefore, I need something I can set - which is always reset when XBMC starts.
Was thinking of using:
xbmc.executebuiltin("Skin.SetBool(script_running)")
inside the service.
Then, in my other script checking if this was set.
But, result = xbmc.executebuiltin('Skin.HasSetting(script_running)') always returns None
The service will also be shutdown unexpectedly, so it doesn't know when it closes.
Thanks,
Matt
Posts: 2,336
Joined: Sep 2006
Reputation:
311
Of, if XBMC had a method same as os.getpid() (get process id) that worked across all platforms?
Or, some other value that changes on startup but remains constant?
Posts: 793
Joined: Oct 2010
Reputation:
17
You can also periodically save a time stamp to a file or database. Check the timestamp from the other add-on. If the timestamp is older than the interval, the service has died.
Posts: 793
Joined: Oct 2010
Reputation:
17
Or if the user disabled the service ;)
Posts: 2,336
Joined: Sep 2006
Reputation:
311
If the service has been disabled, then they won't be able to get to the default.py anyway?
My structure is:
addon folder
- default.py (just runs service if not running then opens the addon settings dialog)
- service.py
Posts: 2,336
Joined: Sep 2006
Reputation:
311
2013-07-02, 13:45
(This post was last modified: 2013-07-02, 13:53 by matthuisman.)
Now...
Any ideas on how to tell if the service script is being called on-boot, or being called via another method (enable/disable script, via another script)
For another script, it's easy - just pass an argument.
However, for the script to detect if it's being started via boot or script enable is a bit trickier.
Was thinking I could set a window property of "hasrun" that get's set the first time the script is run.
Therefore, if it runs again, it knows it has already been run and therefore getting re-enabled.
However, this won't work with the situation where you disable the script, power down XBMC, power on, then re-enable script.
Any ideas?
Maybe check system up-time?
If this is greater than 10seconds, then assume the script has been enabled.
Posts: 2,336
Joined: Sep 2006
Reputation:
311
Got it:
if ( xbmcgui.getCurrentWindowId() == 10000 ):
#running from boot
else:
#not running from boot
Posts: 793
Joined: Oct 2010
Reputation:
17
What if the user triggers the script to start from the home screen?
Posts: 2,336
Joined: Sep 2006
Reputation:
311
Hi.
The script is a service so it runs when XBMC boots.
XBMC always defaults to home screen on boot.
So, if the service runs and detects it's on the home screen, I know the script is being run "on boot".
But, if the service runs and it's not on the home screen, I know the script has been "enabled" via the "addon information dialog"
My service continually runs, but needs to run a special function only if "on boot"