2017-10-15, 06:25
(2016-02-02, 16:10)Milhouse Wrote:(2016-02-02, 13:14)lstar337 Wrote: I gave it a go, but I get an addon error. Looking in the log it says this:
Ah right, you don't want to execute this script in the context of the Kodi process.
Here's a fix... http://sprunge.us/eLXN
Put this alongside the texturecache.py script, call it shell.py and give it execute permissions - on Linux:
Code:wget http://sprunge.us/eLXN -O ~/.kodi/userdata/shell.py && chmod +x ~/.kodi/userdata/shell.py
Now your Runscript() call needs to be (note this assumes the texturecache.py script is alongside the shell.py script, otherwise specify the full path to texturecache.py - don't use special://whatever):
Code:RunScript(special://profile/shell.py,./texturecache.py,c)
For instance to map this to a remote control button:
Code:<red>XBMC.RunScript(special://profile/shell.py,./texturecache.py,c)</red>
As a bonus you'll get notifications on start and finish, and you won't be able to run multiple instances (which wouldn't be good).
@milhouse:
While the solution via the shell.py script is working fine on my KODI Krypton v17.4 installations under LibreELEC on my Raspberry Pi and ANDROID box, I can't get it to work on my PC using KODI for windows...
First problem:
As there are no "/var/run/" directories on the KODI installation on my PC running Windows 7, I replaced the line from
pidfile = "/var/run/shellpy.pid"
to
pidfile = "C:\Users\Stefan\AppData\Roaming\KODI\userdata\shellpy.pid"
-> problem solved
Second problem:
Trying to run the script shell.py throws the following excepton in the KODI log:
05:43:21.729 T:2148 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.WindowsError'>
Error Contents: [Error 2] Das System kann die angegebene Datei nicht finden
Traceback (most recent call last):
File "C:\Users\Stefan\AppData\Roaming\Kodi\userdata\shell.py", line 31, in <module>
shellnotify(sys.argv[1:])
File "C:\Users\Stefan\AppData\Roaming\Kodi\userdata\shell.py", line 24, in shellnotify
notify("Starting...", " ".join(args))
File "C:\Users\Stefan\AppData\Roaming\Kodi\userdata\shell.py", line 11, in notify
shellcmd(["kodi-send", "--action", "Notification(%s,%s)" % (header, text)])
File "C:\Users\Stefan\AppData\Roaming\Kodi\userdata\shell.py", line 7, in shellcmd
process = subprocess.Popen(args, stderr=open(os.devnull, 'w'))
File "C:\Program Files (x86)\Kodi\system\python\Lib\subprocess.py", line 390, in __init__
errread, errwrite)
File "C:\Program Files (x86)\Kodi\system\python\Lib\subprocess.py", line 640, in _execute_child
startupinfo)
WindowsError: [Error 2] Das System kann die angegebene Datei nicht finden
-->End of Python script error
I assume that the "WindowsError: [Error 2] Das System kann die angegebene Datei nicht finden" (translated to english: "The system can't find the specified file") is caused by the missing "kodi-send" command under Windows, right?
I was not able to find an alternative command line tool for windows, but maybe I didn't use the appropriate search terms, since I'm a noob regarding python programming...
So - how could I get a "work-around" for this problem?