True xbmc File Paths

Requests, suggestions, support, and everything else python / plugin related.
Post Reply
mwaterbu
Posts: 41
Joined: Mon Jan 28, 2013 3:22 am
Been thanked: 4 times

True xbmc File Paths

Post by mwaterbu »

Hello, just wondering what the proper way is to retrieve the true file path of the xbmc folder from python. Using

Code: Select all

os.getcwd()
always returns the Q: drive.
I have also tried using xbmc.validatePath and xbmc.translatePath to no avail. I am looking to get a response such as E:\xbmc.
In the log I see:

Code: Select all

NOTICE: Q:// is mapped to: E:\xbmc
but how can I get that from python?
Thank you for the help.
User avatar
Dom DXecutioner
Posts: 585
Joined: Thu Jul 05, 2012 11:59 pm
Location: California
Has thanked: 249 times
Been thanked: 219 times
Contact:

Re: True xbmc File Paths

Post by Dom DXecutioner »

here's a couple of operations to call xbmc's special directories:

os.getcwd() - This will fetch the current root directory where the script is being call from

special://xbmc - XBMC' installation root directory. This path is read-only contains the XBMC binary, support libraries and default configuration files, skins, scripts and plugins. Users should not modify files or install

special://home - XBMC's user specific (OS user) configuration directory. This path contains a writable version of the special://xbmc directories. Any addons should be installed here

special://profile - XBMC's currently active profile directory. This directory points at special://masterprofile/profile_name (or special://masterprofile if no profile is in use) and contains per profile overrides for settings and sources.

special://skin - This path points to the currently active skin's root directory.

Code: Select all

import xbmc
import os

print "OS.CURRENT.DIRECTORY:      " + os.getcwd()
print "XBMC.SPECIAL.XBMC: 		" + xbmc.translatePath( "special://xbmc" )
print "XBMC.SPECIAL.HOME: 		" + xbmc.translatePath( "special://home" )
print "XBMC.SPECIAL.PROFILE: 	" + xbmc.translatePath( "special://profile" )
hope that helps...
Image
mwaterbu
Posts: 41
Joined: Mon Jan 28, 2013 3:22 am
Been thanked: 4 times

Re: True xbmc File Paths

Post by mwaterbu »

Thanks for your response Dom, but I don't think you understand what I am looking for...
The code you provided:

Code: Select all

xbmc.translatePath( "special://xbmc" )
and

Code: Select all

xbmc.translatePath( "special://home" )
only return the Q:\ drive, which I do not want. I am trying to get something like E:\xbmc.
Thanks!
mwaterbu
Posts: 41
Joined: Mon Jan 28, 2013 3:22 am
Been thanked: 4 times

Re: True xbmc File Paths

Post by mwaterbu »

Thanks again for the help, I figured out what I needed to do, posting this here just in case anyone else may find it helpful.
I know it may be a little "too hacky" but I am just opening the log file and reading the file directory from there.

Code: Select all

if (os.path.exists(xbmc.translatePath("special://xbmc") + "xbmc.log")):
		f = open(xbmc.translatePath("special://xbmc") + "xbmc.log", "r")
		for line in f:
			idx = string.find(line, "The executable running is: ")
			if (idx != -1):
				return line[idx + 27:string.rfind(line, os.sep) + 1]
This will return to me:

Code: Select all

E:\XBMC\
User avatar
Rocky5
Posts: 974
Joined: Sat Feb 08, 2014 5:27 am
Has thanked: 101 times
Been thanked: 257 times

Re: True xbmc File Paths

Post by Rocky5 »

mwaterbu wrote:Thanks again for the help, I figured out what I needed to do, posting this here just in case anyone else may find it helpful.
I know it may be a little "too hacky" but I am just opening the log file and reading the file directory from there.

Code: Select all

if (os.path.exists(xbmc.translatePath("special://xbmc") + "xbmc.log")):
		f = open(xbmc.translatePath("special://xbmc") + "xbmc.log", "r")
		for line in f:
			idx = string.find(line, "The executable running is: ")
			if (idx != -1):
				return line[idx + 27:string.rfind(line, os.sep) + 1]
This will return to me:

Code: Select all

E:\XBMC\
That doesn't seem to work any more :-(

Code: Select all

CharCount = 100 # How many characters you want after 'The executable running is: '
with open(xbmc.translatePath("special://xbmc") + "xbmc.log", "r") as XBMCLOG:
    for line in XBMCLOG:
        left,sep,right = line.partition("The executable running is: ")
        if sep:
            XBMCPath = (right[:CharCount])
The above will give you the path from the log.
Download Xbox Softmodding Tool & Extras Disc
XBMC4Kids Mod


Xbox Gamertag = Connxtion
PSN ID = JCRocky5
Post Reply