Trouble getting Python script to run from menu item (Amber)


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/’ but when I try to activate that action the script doesn’t seem to be running.

I tried writing a test script as follows:

import os

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.


How are you launching it manually? are you just doing ./ or are you doing python3

One thing it could be is that the execute permission bit isn’t set on the file.

manually ./
also runs correctly from cron

ok, the execute bit must be set then, i’m out of ideas.

I appreciate the effort. Is XBMC.RunScript() still the correct command? The place I found it online was a couple years old.

I don’t really know anything about the topic but I thought this type of thing was done with xbmc.executebuiltin('RunScript(script.myscript)').

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/' defined
Tried again without the prefix and I get:
ERROR <general>: CPythonInvoker(179): python script "/home/osmc/BG_Gen/" 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/”

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
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.

1 Like