[RELEASE] Execute user scripts on specific XBMC actions (play starts/stops...)

  Thread Rating:
  • 4 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
RaZer0r Offline
Junior Member
Posts: 3
Joined: Aug 2015
Reputation: 0
Post: #271
Hi, I was looking for a way to mount my nfs drives OS level instead of using the builtin nfs:// library as there is a big performance issues over vpn (my storage is located halfway across the world ;-) ).

So, I wrote the startup_script.sh and added it to the startup option

But apparently there seems to be an issue... see logs below

Kodi.log:
http://pastebin.com/peJQLEFq

script:
-rwxr-xr-x 1 rein staff 196B Aug 28 13:40 startup_script.sh


Reins-MacBook-Pro:userdata rein$ cat startup_script.sh
#!/bin/bash
mkdir /Volumes/Series
mkdir /Volumes/Movies
mount -t nfs 192.168.22.51:/mnt/DroboFS/Shares/Series /Volumes/Series
mount -t nfs 192.168.22.51:/mnt/DroboFS/Shares/Movies /Volumes/Movies

Can you help?
find quote
KenV99 Offline
Fan
Posts: 322
Joined: Nov 2013
Reputation: 10
Post: #272
(Yesterday 14:09)RaZer0r Wrote:  Hi, I was looking for a way to mount my nfs drives OS level instead of using the builtin nfs:// library as there is a big performance issues over vpn (my storage is located halfway across the world ;-) ).

So, I wrote the startup_script.sh and added it to the startup option

But apparently there seems to be an issue... see logs below

Kodi.log:
http://pastebin.com/peJQLEFq

script:
-rwxr-xr-x 1 rein staff 196B Aug 28 13:40 startup_script.sh


Reins-MacBook-Pro:userdata rein$ cat startup_script.sh
#!/bin/bash
mkdir /Volumes/Series
mkdir /Volumes/Movies
mount -t nfs 192.168.22.51:/mnt/DroboFS/Shares/Series /Volumes/Series
mount -t nfs 192.168.22.51:/mnt/DroboFS/Shares/Movies /Volumes/Movies

Can you help?

Very odd!

The log indicates that your version of python doesn't support subprocess.check_ouput:
Code:
13:56:13 T:4589146112  NOTICE: $$$ [xbmc.callbacks2] - Command for onStartup resulted in ERROR: <attribute 'message' of 'exceptions.BaseException' objects>
                                            Traceback (most recent call last):
                                              File "/Users/rein/Library/Application Support/Kodi/addons/service.xbmc.callbacks2-master/default.py", line 515, in run
                                                result = subprocess.check_output(margs, shell=self.needs_shell, stderr=subprocess.STDOUT)
                                            AttributeError: 'module' object has no attribute 'check_output'

but clearly that is part of python 2.7:
https://docs.python.org/2/library/subpro...eck_output

I don't know if anyone else running on OSX has experienced this issue. I googled around and can't seem to find that this is an issue specific to OSX.
Perhaps others on OSX can chime in.

You could try editing line 515 to be subprocess.call instead of subprocess.check_output
find quote
RaZer0r Offline
Junior Member
Posts: 3
Joined: Aug 2015
Reputation: 0
Post: #273
OSX Yosemite has python 2.6 and 2.7.10 installed, with 2.7 being the default.

I both checked 2.6 and 2.7, but the subroutine still failed...
With switching to the subprocess.call it worked.

When you want me to do some more testing let me know :-)
find quote
RaZer0r Offline
Junior Member
Posts: 3
Joined: Aug 2015
Reputation: 0
Post: #274
(Yesterday 14:51)KenV99 Wrote:  
(Yesterday 14:09)RaZer0r Wrote:  Hi, I was looking for a way to mount my nfs drives OS level instead of using the builtin nfs:// library as there is a big performance issues over vpn (my storage is located halfway across the world ;-) ).

So, I wrote the startup_script.sh and added it to the startup option

But apparently there seems to be an issue... see logs below

Kodi.log:
http://pastebin.com/peJQLEFq

script:
-rwxr-xr-x 1 rein staff 196B Aug 28 13:40 startup_script.sh


Reins-MacBook-Pro:userdata rein$ cat startup_script.sh
#!/bin/bash
mkdir /Volumes/Series
mkdir /Volumes/Movies
mount -t nfs 192.168.22.51:/mnt/DroboFS/Shares/Series /Volumes/Series
mount -t nfs 192.168.22.51:/mnt/DroboFS/Shares/Movies /Volumes/Movies

Can you help?

Very odd!

The log indicates that your version of python doesn't support subprocess.check_ouput:
Code:
13:56:13 T:4589146112  NOTICE: $$$ [xbmc.callbacks2] - Command for onStartup resulted in ERROR: <attribute 'message' of 'exceptions.BaseException' objects>
                                            Traceback (most recent call last):
                                              File "/Users/rein/Library/Application Support/Kodi/addons/service.xbmc.callbacks2-master/default.py", line 515, in run
                                                result = subprocess.check_output(margs, shell=self.needs_shell, stderr=subprocess.STDOUT)
                                            AttributeError: 'module' object has no attribute 'check_output'

but clearly that is part of python 2.7:
https://docs.python.org/2/library/subpro...eck_output

I don't know if anyone else running on OSX has experienced this issue. I googled around and can't seem to find that this is an issue specific to OSX.
Perhaps others on OSX can chime in.

You could try editing line 515 to be subprocess.call instead of subprocess.check_output

So: Something really weird happens now.. The first testings it worked fine, but now not anymore Sad. The only thing I did was adding a stop script (to unmount the volumes) but now nothing gets ran. The log does say the script is being executed...
I tried removing the plugin and reinstalling it (including removing the userdata/service plugin folder) but no go.. it just won't mount the disks anymore...

Any way to debug the outputs of the scripts ran? (although my mount script should not give any output anyway)

Code:
18:51:17 T:4580925440  NOTICE: Thread LanguageInvoker start, auto delete: false
18:51:17 T:140735210930944  NOTICE: Previous line repeats 6 times.
18:51:17 T:140735210930944  NOTICE: initialize done
18:51:17 T:140735210930944  NOTICE: Running the application...
18:51:17 T:140735210930944  NOTICE: starting zeroconf publishing
18:51:17 T:140735210930944  NOTICE: starting upnp client
18:51:17 T:4598071296  NOTICE: Thread JobWorker start, auto delete: true
18:51:17 T:140735210930944  NOTICE: ES: Starting event server
18:51:17 T:4601290752  NOTICE: Thread EventServer start, auto delete: false
18:51:17 T:4601290752  NOTICE: ES: Starting UDP Event server on 0.0.0.0:9777
18:51:17 T:4601290752  NOTICE: UDP: Listening on port 9777
18:51:17 T:4601827328  NOTICE: Thread TCPServer start, auto delete: false
18:51:17 T:4580925440  NOTICE: -->Python Interpreter Initialized<--
18:51:17 T:4642508800  NOTICE: Previous line repeats 6 times.
18:51:17 T:4642508800  NOTICE: Thread JobWorker start, auto delete: true
18:51:17 T:4642508800   ERROR: InputStream: Error opening, /Volumes/Movies/Fast and Furious/Fast & Furious.2009.1080p.BluRay.x264.anoXmous_.mp4
18:51:17 T:4596461568  NOTICE: script.tv.show.next.aired: ### TV Show - Next Aired starting background proc (6.0.14)
18:51:17 T:4596998144  NOTICE:  StorageServer Module loaded RUN
18:51:17 T:4596998144  NOTICE: StorageClient-2.5.4 Starting server
18:51:17 T:4597534720  NOTICE: $$$ [xbmc.callbacks2] - Starting xbmc.callbacks2 version 0.1.0
18:51:17 T:4597534720  NOTICE: $$$ [xbmc.callbacks2] - Executing command: [[u'/Users/rein/Library/Application Support/Kodi/userdata/startup_script.sh']] for event: onStartup
18:51:17 T:4597534720  NOTICE: $$$ [xbmc.callbacks2] - Command for onStartup executed successfully[/quote]

Added logs*
(This post was last modified: Yesterday 19:18 by RaZer0r.)
find quote
KenV99 Offline
Fan
Posts: 322
Joined: Nov 2013
Reputation: 10
Post: #275
(Yesterday 18:49)RaZer0r Wrote:  So: Something really weird happens now.. The first testings it worked fine, but now not anymore Sad. The only thing I did was adding a stop script (to unmount the volumes) but now nothing gets ran. The log does say the script is being executed...
I tried removing the plugin and reinstalling it (including removing the userdata/service plugin folder) but no go.. it just won't mount the disks anymore...

Any way to debug the outputs of the scripts ran? (although my mount script should not give any output anyway)

Code:
18:51:17 T:4580925440  NOTICE: Thread LanguageInvoker start, auto delete: false
18:51:17 T:140735210930944  NOTICE: Previous line repeats 6 times.
18:51:17 T:140735210930944  NOTICE: initialize done
18:51:17 T:140735210930944  NOTICE: Running the application...
18:51:17 T:140735210930944  NOTICE: starting zeroconf publishing
18:51:17 T:140735210930944  NOTICE: starting upnp client
18:51:17 T:4598071296  NOTICE: Thread JobWorker start, auto delete: true
18:51:17 T:140735210930944  NOTICE: ES: Starting event server
18:51:17 T:4601290752  NOTICE: Thread EventServer start, auto delete: false
18:51:17 T:4601290752  NOTICE: ES: Starting UDP Event server on 0.0.0.0:9777
18:51:17 T:4601290752  NOTICE: UDP: Listening on port 9777
18:51:17 T:4601827328  NOTICE: Thread TCPServer start, auto delete: false
18:51:17 T:4580925440  NOTICE: -->Python Interpreter Initialized<--
18:51:17 T:4642508800  NOTICE: Previous line repeats 6 times.
18:51:17 T:4642508800  NOTICE: Thread JobWorker start, auto delete: true
18:51:17 T:4642508800   ERROR: InputStream: Error opening, /Volumes/Movies/Fast and Furious/Fast & Furious.2009.1080p.BluRay.x264.anoXmous_.mp4
18:51:17 T:4596461568  NOTICE: script.tv.show.next.aired: ### TV Show - Next Aired starting background proc (6.0.14)
18:51:17 T:4596998144  NOTICE:  StorageServer Module loaded RUN
18:51:17 T:4596998144  NOTICE: StorageClient-2.5.4 Starting server
18:51:17 T:4597534720  NOTICE: $$$ [xbmc.callbacks2] - Starting xbmc.callbacks2 version 0.1.0
18:51:17 T:4597534720  NOTICE: $$$ [xbmc.callbacks2] - Executing command: [[u'/Users/rein/Library/Application Support/Kodi/userdata/startup_script.sh']] for event: onStartup
18:51:17 T:4597534720  NOTICE: $$$ [xbmc.callbacks2] - Command for onStartup executed successfully[/quote]

Added logs*

Does your script run successfully when running it from the addon settings page?
Did you reset the execute bits on the scripts after reinstalling?

In any case, I pushed an update to github that checks if running OSX and uses subprocess call instead of check_output.
https://github.com/KenV99/service.xbmc.callbacks2

EDIT: I pushed another update. Please download and try again using Test from Settings. Now on OSX it tries to set the execute bit and then uses subprocess.Popen and Popen.communicate to grab the output from the script (that's why I was using subprocess.check_ouput - so you had some feedback for troubleshooting). When you execute via Test, the output from the script, including errors should be displayed in a dialog box (poorly formatted, but there are limits here Smile )
(This post was last modified: Today 14:19 by KenV99.)
find quote
Post Reply