I’m running 2022.03-1 on a Pi 4 (not updated because I’ve done several modifications and don’t want them to break when I update). I’m using the Amber skin, and I’ve written a program that reads some data from a text file and uses it to draw a calendar, which I use as the background for a menu subitem. I’ve written a script that will refresh the calendar image and delete its entry in the image cache, and that is running correctly from crontab at 12:01AM daily.
What I’m trying to do now is to create a menu subitem that will allow me to run that script manually in case I’ve changed the data and want to refresh without waiting for midnight. I added a menu item with the action: ‘XBMC.RunScript(/home/osmc/BG_Gen/redraw.py)’ but when I try to activate that action the script doesn’t seem to be running.
I tried writing a test script as follows:
#!/usr/bin/python3
import os
os.chdir('/home/osmc/BG_Gen/')
os.system('touch testresult')
and added it to the menu in the same way, but it doesn’t generate the testresult file (I used find to ensure that it’s not putting it somewhere weird.). It runs correctly if called from bash, even if called from another directory.
I’m stumped at this point. If anyone can see a problem with my method, I’d appreciate any advice.
I think that’s to run an XBMC function from within a python script. I tried it anyway, as well as trying RunScript() without the XBMC prefix, but nothing seems to have worked. I wonder if there are limitations on what RunScript() will accept, like maybe it needs to be in a specific directory or something.
Found this in kodi.log immediately after an attempt: ERROR <general>: Keymapping error: no such action 'xbmc.runscript(/home/osmc/bg_gen/test.py)' defined
Tried again without the prefix and I get: ERROR <general>: CPythonInvoker(179): python script "/home/osmc/BG_Gen/test.py" does not exist
Yet, it most certainly does exist. I wonder if the invoker considers ~/.kodi/ to be the root. I’ll do a little testing.
I thought it was to run a Kodi function and that function is “runscript” and I pulled that out of the skinning wiki. But, as I said, I really don’t know anything about the topic at hand. Maybe try from the terminal…
kodi-send -a “RunScript(/home/osmc/BG_Gen/redraw.py)”
to be able to seperate if the issue if with the script or with how your executing it from the skin.
Getting ERROR <general>: ExecuteAsync - Not executing non-existing script test.py
It seems to want the script to exist in a specific location or something. I’ll keep hunting around. Thank you for the tip about kodi-send, that’ll save a lot of time.