Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
There are people having issues with the svn repo trying to install items.
i have not changed anything, so on windows i would install to translatePath("U:\\"...).
should this be the folder xbmc was installed to. it is installing items there, whether using -p or not. are we now suppose to use the special:// folders and eliminate translatePath.
will you post a list of these special:// folders so everyone can see.
there shoulod be only one path for scripters to use for things like this. it should be transparent to the scripter. like U:\\ was.
thanks
Posts: 901
Joined: Feb 2005
Reputation:
3
so how should a path mapping, such as the following, be done properly ?
DIR_USERDATA = os.path.join( "T:"+os.sep,"script_data", __scriptname__ )
would it be:
DIR_USERDATA = os.path.join( "special://masterprofile/", "script_data", __scriptname__ )
if that is the case, should the it also use os.sep making it more platform portable?
ie.
DIR_USERDATA = os.path.join( "special:" + os.sep + "masterprofile", "script_data", __scriptname__ )
I've only noticed this with T: drive myself so far. and not on xbox, just windows. Is this 'new' behaviour being merged back to xbox ?
cheers
BBB
Posts: 12,706
Joined: Nov 2003
Reputation:
129
spiff
Team-Kodi Member
Posts: 12,706
yeah, it is being merged back.
your example is correct, but you would NEVER use a \, it is always /. i.e. in your case
special://masterprofile/script_data/scriptname/
Posts: 901
Joined: Feb 2005
Reputation:
3
2009-02-06, 17:40
(This post was last modified: 2009-02-06, 17:44 by BigBellyBilly.)
so is using a / instead of os.sep is enough to make it work an all platforms ?
DIR_USERDATA = os.path.join( "special://masterprofile/", "script_data", __scriptname__ )
and if doing a cmd such as os.listdir() then it should go throu translatePath() too ?
ie.
os.listdir(xbmc.translatepath(DIR_USERDATA))
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
i don't think you want to use os.path.join() as that would insert a \ on windows/xbox
"/".join([ "special://masterprofile", "script_data", __scriptname__ ])
Posts: 901
Joined: Feb 2005
Reputation:
3
yes it does insert \ and presumably / on linux - but is that a bad thing as it does resolve the path correctly (only tested on windows for now)
ie.
DIR_USERDATA = os.path.join( "special://masterprofile","script_data", __scriptname__ )
becomes
DIR_USERDATA=special://masterprofile\script_data\myscriptname
which I now push throu xbmc.translatePath(USERDATA) when I do any os.path commands.
i thought the whole idea was to use os.path inorder to make correctly formed path strings for that platform ?
BBB
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
xbmc.translatePath("special://home/")
no matter if i launch with -p or not, is always "F:\source\XBMC-Linux" on windows.
is this correct? seems wrong
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
BBB, it is always a url address now.
Posts: 1,331
Joined: Jan 2008
Reputation:
3
rwparris2
Team-XBMC Python Developer
Posts: 1,331
any chance of changing xbmc.TranslatePath() to 'fix' incorrect separators from os.path.join?
using '/'.join() makes sense once you realize it is always a url, but at first it is extremely unintuitive compared to os.path.join()
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
2009-02-06, 18:55
(This post was last modified: 2009-02-06, 18:58 by Nuka1195.)
special:://home/ is wrong on windows 7/vista 64bit.
i can't see if there is a special case for WIN64 for vista, but there may need to be one similar to linux. as i guess the items should go in the roaming folder?
edit: which according to environment variables it is APPDATA which equals c:\Users\Scott\AppData\Roaming
Posts: 901
Joined: Feb 2005
Reputation:
3
a sticky with examples explaining all this seems a good idea.
if url / is now the way to build a path across all platforms, can you see any reason not to just concat using simple string + now ?
ie.
DIR_USERDATA = "special://masterprofile/script_data/" + __scriptname__
Posts: 3,909
Joined: Dec 2004
Reputation:
20
Nuka1195
Skilled Python Coder
Posts: 3,909
i see where home is set for windows. it has a fixme note, so if i can figure out how to get an env variable value, use that there. APPDATA exists on xp and vista
Posts: 901
Joined: Feb 2005
Reputation:
3
in order to ease the transition of all scripts rather than the majority needing fixing, what about having translatePath() convert old mappings to the new special:// equiv?