python path problems

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
mkortstiege Offline
Team-Kodi Developer
Posts: 2,963
Joined: Jan 2008
Reputation: 8
Location: Germany
Post: #1
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
find quote
wattazoum Offline
Team-XBMC Linux Packager
Posts: 315
Joined: Mar 2008
Reputation: 1
Location: Antibes, France
Post: #2
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 ).
find quote
wattazoum Offline
Team-XBMC Linux Packager
Posts: 315
Joined: Mar 2008
Reputation: 1
Location: Antibes, France
Post: #3
What is weird is that this is working with the version on the PPA ( 2.1a1p1 ) and not with the svn ...
find quote
mkortstiege Offline
Team-Kodi Developer
Posts: 2,963
Joined: Jan 2008
Reputation: 8
Location: Germany
Post: #4
Could you let me know what revision is the 2.1a1p1? Maybe it could be fixed easily.
find quote
wattazoum Offline
Team-XBMC Linux Packager
Posts: 315
Joined: Mar 2008
Reputation: 1
Location: Antibes, France
Post: #5
it was based on SVN REV 12195
find quote
wattazoum Offline
Team-XBMC Linux Packager
Posts: 315
Joined: Mar 2008
Reputation: 1
Location: Antibes, France
Post: #6
I have tried with the latest SVN :

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

and I get the right path.
find quote
mkortstiege Offline
Team-Kodi Developer
Posts: 2,963
Joined: Jan 2008
Reputation: 8
Location: Germany
Post: #7
Hm. Appending "lib" to sys.path should result in "lib" Smile But ill test it asap.
find quote