• 1
  • 2(current)
  • 3
  • 4
  • 5
  • 22
Release Execute user tasks for Kodi events (callbacks ver2)
#16
LuffarJoh:

Download the latest enter a user and password in an HTTP task in the settings and see if it works for you. It seems to be working for me.
Reply
#17
ok not it works without an exception, but i still have this error when trying to run StartPVRManager / StopPVRManager as listed in http://kodi.wiki/view/List_of_built-in_functions

Code:
16:02:08 T:139745476732672   DEBUG: $$$ [kodi.callbacks] - Running Test for Event: E1
16:02:08 T:139745476732672   DEBUG: $$$ [kodi.callbacks] - Settings for test read
16:02:08 T:139745476732672   DEBUG: $$$ [kodi.callbacks] - Creating subscriber for test
16:02:08 T:139745476732672   DEBUG: $$$ [kodi.callbacks] - Test subscriber created successfully
16:02:08 T:139745476732672   DEBUG: $$$ [kodi.callbacks] - Running test
16:02:08 T:139745476732672   DEBUG: $$$ [kodi.callbacks] - Task starting for onStartup
16:02:08 T:139745476732672 WARNING: CSkinInfo: failed to load skin settings
16:02:08 T:139748258080704   ERROR: ExecuteAsync - Not executing non-existing script StopPVRManager

Shouldn't it work this way?
Reply
#18
Not all PVR clients have all functions implemented in the way you think.
Using the DEMO client, executing 'StartPVRManager' gives me the following entries in the log:

Code:
12:37:28 T:60040  NOTICE: PVRManager - stopping
12:37:29 T:60040  NOTICE: PVRManager - starting up
12:37:29 T:61980  NOTICE: Thread PVRManager start, auto delete: false
12:37:29 T:59656  NOTICE: Thread PVRClient start, auto delete: false
12:37:29 T:63292  NOTICE: Thread PVRGUIInfo start, auto delete: false
12:37:29 T:61980  NOTICE: EPG::CEpgContainer::Start - EPG thread started
12:37:29 T:61160  NOTICE: Thread EPGUpdater start, auto delete: false

So I have a feeling it is your PVR client's implementation.
Reply
#19
i think the script should exist as it works when called via a external python script
Code:
xbmc.executebuiltin('xbmc.' + 'StopPVRManager')

does start / stop the service, any idea how to debug further or is there a method to list all available builtin commands?

edit: what looks strange to me - ExecuteAsync - Not executing non-existing script xbmc.StartPVRManager, shouldn't this be a command and mybe a script is geting called instead of a command?
Reply
#20
ok, this is the bug: internal command calls external script: referenced a external script ("/path/to/script.py") having selected the "Builtin" dropdown and its getting executed!


https://github.com/KenV99/service.kodi.c...tin.py#L53

Code:
if len(self.runtimeargs) > 0:
                result = xbmc.executebuiltin('XBMC.RunScript(%s, %s)' % (self.taskKwargs['builtin'], args))
            else:
                result = xbmc.executebuiltin('XBMC.RunScript(%s)' % self.taskKwargs['builtin'])

should be
Code:
if len(self.runtimeargs) > 0:
                result = xbmc.executebuiltin('%s, %s' % (self.taskKwargs['builtin'], args))
            else:
                result = xbmc.executebuiltin('%s' % self.taskKwargs['builtin'])
Reply
#21
(2016-01-18, 11:53)dfns Wrote: ok, this is the bug: internal command calls external script: referenced a external script ("/path/to/script.py") having selected the "Builtin" dropdown and its getting executed!


https://github.com/KenV99/service.kodi.c...tin.py#L53

Code:
if len(self.runtimeargs) > 0:
                result = xbmc.executebuiltin('XBMC.RunScript(%s, %s)' % (self.taskKwargs['builtin'], args))
            else:
                result = xbmc.executebuiltin('XBMC.RunScript(%s)' % self.taskKwargs['builtin'])

should be
Code:
if len(self.runtimeargs) > 0:
                result = xbmc.executebuiltin('%s, %s' % (self.taskKwargs['builtin'], args))
            else:
                result = xbmc.executebuiltin('%s' % self.taskKwargs['builtin'])

Thx for finding that. I pushed an update.
Reply
#22
(2016-01-17, 01:29)KenV99 Wrote: LuffarJoh:

Download the latest enter a user and password in an HTTP task in the settings and see if it works for you. It seems to be working for me.

Thanks! Sorry for not getting back to you, been busy the last couple of days. I did a brief test today when I had some time over, but unfortunately it didn't work. I'll make a more thorough test and intercept the traffic to see where it's going wrong. I'll let you know!
Reply
#23
Is it possible to add an event for quit Kodi? There's one for shutdown but i'd need to run a script on exiting Kodi.
Reply
#24
(2016-01-20, 19:40)bigbadrabbit Wrote: Is it possible to add an event for quit Kodi? There's one for shutdown but i'd need to run a script on exiting Kodi.

I'm not sure what you mean by onQuit. OnShutdown is the last thing run by the addon before it exits.

If you mean you want to execute a task after Kodi has completely exited, then there is no straightforward way to do that. You would either need to start Kodi itself from a script that halts execution after it runs Kodi and then executes whatever you want after Kodi ends. This would be os dependent. Or you could use the addon to execute a script that polls whether Kodi is still running until it is not running and then runs your task. Which again the implementation would be os dependent.
Reply
#25
(2016-01-20, 19:40)bigbadrabbit Wrote: Is it possible to add an event for quit Kodi? There's one for shutdown but i'd need to run a script on exiting Kodi.

So if you actually want to try to run something after Kodi exits, I added Kodi's pid as possible command line output for the onShutdown event and I added the ability for the addon to not wait for a script to return.

So if you setup onShutdown to run a script and not wait and pass out Kodi's pid, you could possibly do something like this in your script:
Code:
#!/usr/bin/env bash
while kill -0 $1 > /dev/null 2>&1
do
    sleep 0.2
done
# insert your code here

Using kill -0 to test the passed in pid to see if it is running.
I don't have an OSX system to test on at the moment, but I think that you get the idea.
Reply
#26
cool plugin - thanks a lot for sharing.

forgive me if this is a stupid question, but I'm really not a coder. I setup a bash script that sends a remote applescript to another machine on the network that is controlling some smart appliances in the house. Now everything works absolutely great so far. The problem is, that I cannot find a way to make a distinction between video and audio playback for the OnPlayBack events. I suppose it has to do with the variable substitution but I couldn't figure out how to use it.

I tried to pass %mt and pick it up in the script as $mt, if $mt was not "music" it should ignore the commands -> as you can guess that didn't work the way I hoped for.

can someone point me into the right direction please. while it is cool to dim down the lights when a movie starts, it's quite annoying if it does the same while I'm playing the hottest tunes for our dinner guests :-)
Reply
#27
(2016-01-24, 18:29)xbmosx Wrote: cool plugin - thanks a lot for sharing.

forgive me if this is a stupid question, but I'm really not a coder. I setup a bash script that sends a remote applescript to another machine on the network that is controlling some smart appliances in the house. Now everything works absolutely great so far. The problem is, that I cannot find a way to make a distinction between video and audio playback for the OnPlayBack events. I suppose it has to do with the variable substitution but I couldn't figure out how to use it.

I tried to pass %mt and pick it up in the script as $mt, if $mt was not "music" it should ignore the commands -> as you can guess that didn't work the way I hoped for.

can someone point me into the right direction please. while it is cool to dim down the lights when a movie starts, it's quite annoying if it does the same while I'm playing the hottest tunes for our dinner guests :-)

Yes, you should pass out %mt

Please post your actual script.
For bash it should look like:
Code:
#!/usr/bin/env bash

if [ "$1" != "music" ]; then
   echo NOT AUDIO
fi

Replace the echo line with your code for your lights. The spaces after the open bracket and before the close bracket are important as are the quotes around the "$1".
$1 gives the first argument, $2 the second. I suspect your issue is $mt was either not defined or if you set mt=$1 then your formatting of the if statement was wrong.
Reply
#28
Thanks KenV99 I was able to make it work with your instructions. Very cool.
Reply
#29
(2016-01-14, 21:26)dfns Wrote: ok i'll test it, btw: is the a "return from idle" event?

There is now. It's called 'on Resume After Idle'.
Reply
#30
Thanks for a great plugin Ken.

I want to run a command that normally requires "sudo".
How would I go about doing that?

Thanks for your reply!
P.S.
The version I downloaded still had the "debug = True", causing a (pydevd) import error.
-EDIT-
Maybe you could add a check for the files "pycharm-debug.py3k" and "pycharm-debug.egg", so debug gets skipped if those don't exist...
Reply
  • 1
  • 2(current)
  • 3
  • 4
  • 5
  • 22

Logout Mark Read Team Forum Stats Members Help
Execute user tasks for Kodi events (callbacks ver2)3