Tips for coding python scripts / plugins compatible with Linux, Mac, Windows AND Xbox
using os.getcwd() in conjunction with the recommended url style path divider '/' creates a path with mixed dividers.


DIR_HOME = os.getcwd().replace( ";", "" )
DIR_RESOURCES_LIB = "/".join( [DIR_HOME, "resources", "lib"] )
sys.path.insert(0, xbmc.translatePath(DIR_RESOURCES_LIB) )


C:\Program Files\XBMC\scripts\<scriptname>/resources/lib

which is ugly, but it still works on win32 and xbox (don't know about others)
HOME_DIR is only really used as a base for relative subdirs and it doesnt upset
translatePath() but any recommendations to get a path all using the same divider ?

Note:: xbmc.Language( DIR_HOME ) which appends 'resources' must produce:
C:\Program Files\XBMC\scripts\<scriptname>/resources/

Is this likely to be a future problem ?

Retired from Add-on dev
BBB, do NOT use "/".join() for an actual path.

you use os.cwd() to get the actual current directory, so use os.path.join()

only use "/".join() when you start with a url eg "special://home/"
For python coding questions first see
ok. will do.

Would a special:// that relates to current location ( as found with os.getcwd() ) be a useful one to have too ?
Retired from Add-on dev
Doesn't xbmc python support SYS module
os.getcwd() doesnt always give current directory of script, it depends where the script is RUN from... even on windows or linux..

Try os.path.dirname( sys.argv[0] )
Spread the knowledge, nothing else.Image
Hi, my name is Filipe, and i need some helps. Im new on XBMC development, and i dont now where can i find material to learn how to use python on XBMC.
I need do some modifications in the pythons code. Someone can help me?


Logout Mark Read Team Forum Stats Members Help
Tips for coding python scripts / plugins compatible with Linux, Mac, Windows AND Xbox2
This forum uses Lukasz Tkacz MyBB addons.