Kodi Community Forum
python path problems - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: Linux (https://forum.kodi.tv/forumdisplay.php?fid=52)
+---- Thread: python path problems (/showthread.php?tid=32586)



python path problems - mkortstiege - 2008-04-13

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


- wattazoum - 2008-04-13

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


- wattazoum - 2008-04-13

What is weird is that this is working with the version on the PPA ( 2.1a1p1 ) and not with the svn ...


- mkortstiege - 2008-04-13

Could you let me know what revision is the 2.1a1p1? Maybe it could be fixed easily.


- wattazoum - 2008-04-13

it was based on SVN REV 12195


- wattazoum - 2008-04-13

I have tried with the latest SVN :

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

and I get the right path.


- mkortstiege - 2008-04-14

Hm. Appending "lib" to sys.path should result in "lib" Smile But ill test it asap.