Kodi Community Forum

Full Version: python path problems
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

there`s a problem with getting the current working directory while starting python scripts/plugins. Here's an quick example of what it looks like.

Code:
# main import's
import sys
import os

# Shared resources
BASE_RESOURCE_PATH = os.path.join( os.getcwd().replace( ";", "" ), "resources" )
sys.path.append( os.path.join( BASE_RESOURCE_PATH, "lib" ) )

print BASE_RESOURCE_PATH
print sys.path
Results in ..

Quote:1:32:37 T:2694835088 M:1137496064 DEBUG: Python thread: start processing
11:32:37 T:2694835088 M:1137496064 INFO: -->Python Interpreter Initialized<--
11:32:37 T:2694835088 M:1137496064 INFO:
11:32:37 T:2694835088 M:1137496064 INFO: /home/xbmc/XBMC/BUILD/resources
11:32:37 T:2694835088 M:1137496064 INFO:
11:32:37 T:2694835088 M:1137496064 INFO: ['/home/xbmc/XBMC/BUILD/scripts', '/usr/lib/python24.zip', '/usr/lib/python2.4/', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/home/xbmc/XBMC/BUILD/resources/lib']
11:32:37 T:2694835088 M:1137496064 INFO:
11:32:37 T:2694835088 M:1137496064 INFO: Scriptresult: Succes
11:32:37 T:3071489952 M:1137496064 DEBUG: CGUIMediaWindow::GetDirectory (/home/xbmc/XBMC/BUILD/scripts/)

Due to this bug its impossible to run any python script or plugin within the Linux port of XBMC that make use of it (almost all).

Regards
VDRFan
I can confirm this. a lot of python scripts are failing because of that. I believe the path that is returned is the build directory path (it must be hardcoded somewhere ).
What is weird is that this is working with the version on the PPA ( 2.1a1p1 ) and not with the svn ...
Could you let me know what revision is the 2.1a1p1? Maybe it could be fixed easily.
it was based on SVN REV 12195
I have tried with the latest SVN :

sys.path.append("lib")
print sys.path

and I get the right path.
Hm. Appending "lib" to sys.path should result in "lib" Smile But ill test it asap.