Kodi Community Forum

Full Version: Executing a python script from within a skin?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey all,

I'm trying to create a button that launches the AMT script (NOT the plugin). So far the closest I've got is XBMC.RunScript(q:\\scripts\Apple Movie Trailers\default.py). This does indeed run the script, but for some reason running it with that command causes it to look in a different place for its library than running it from the XBMC scripts menu.

If I run it in the scripts menu manually it uses UserData\script_data\Apple Movie Trailers\amt.db, but if I run it with the above command it uses UserData\script_data\amt.db instead.

How can I call it so it will run with the same environment/etc as when I click on it in the scripts menu of XBMC?
I use os.getcwd() in the path, this should not be affected by the way you're running the script.

if a developer can comment on the way os.getcwd() should work in both scenerios. if it is a script problem. i will change it back to use the scriptname (hard coded Apple Movie Trailers). the issue with this is you can't have two different versions of the script, which is only an issue for me probably.

PHP Code:
BASE_DATABASE_PATH xbmc.translatePathos.path.join"P:\\script_data"os.path.basenameos.getcwd() ), "AMT.db" ) ) 
This is not a script problem, more a like a platform problem, it's been a while since I've been working with python, but last time I checked <onclick>XBMC.RunScript(q:\\scripts\Apple Movie Trailers\default.py)<onclick> only works on Windows and Xbox, seeing Linux and OS X store scripts and skins in the 'U drive' as well.

Posted a request about this a while ago, not sure if there has been any progress on this;
http://forum.xbmc.org/showthread.php?tid=34392
I'm using windows, and the call does launch the script but it just seems to launch with a different environment then when I run it manually.
i beleive there is an infolabel that determines platform, so you could have two controls, one special for osx and linux, but i think U:\\ only doesn't work on xbox unless it changed.

i don't know why the getcwd() fails from RunScript(). A developer needs to look into it. maybe submit a bug report to trac http://trac.xbmc.org/ Your login should be the same as here.
the script works fine for me from runscript. i tested it from the favorites menu. my build is not up to date, so i'll see if that changes later today.

this was with windows sdl and xbox.
latest script and latest xbmc svn builing debug works fine, not sure what your issue is.

make sure you have the latest script form the scripting svn.