special:// paths and translatePath
#16
on win32, special://home is always the same as special://xbmc.

This is obviously not correct (as special://xbmc should not be presumed to be writable), but is something we haven't yet fixed.

Also: Note that for backward compatibility, translatePath() currently translates the old style paths as well as the new ones. Remember: Only use it if you are going to be hitting the filesystem for whatever reason.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#17
When I try to import a library I call:

sys.path.append('special://home/scripts/XOT-Uzg.v3/resources/libs/')

Then I call:

import envcontroller

And I get this error under Win32:

unable to get modification time from 'special://home/scripts/XOT-Uzg.v3/resources/libs/envcontroller.py'

If I use the xbmc.translatePath() method on the special://-path and then do sys.path.append everything goes fine.

What could be wrong?
Reply
#18
Supply an example script please. Note that you probably shouldn't be assuming where your script location is.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#19
jmarshall Wrote:Supply an example script please. Note that you probably shouldn't be assuming where your script location is.

Then how should I append a path to the default python path?

Anyways: example script is easy. Download XOT-Uzg.v3.2.0b3 from this site: http://www.rieter.net/uitzendinggemist and replace the first occurence of

sys.path.append(os.path.join(os.getcwd().replace(";",""),'resources','libs'))

in default.py (line 15) with

sys.path.append('special://home/scripts/XOT-Uzg.v3/resources/libs/')

You will get the error from the

import envcontroller
Reply
#20
Fixed in r17694.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#21
jmarshall Wrote:Fixed in r17694.

Cheers,
Jonathan

Thank you for the service Big Grin
Reply
#22
I do keep running into problems trying to get my XOT script to work with the new special:// paths. I use a lot of commands from the Python 'os' library.

I now get these kind of errors:
Code:
18:51:20 T:4452 M:2145390592  NOTICE:   File "D:\XBMC\XBMC_PC\scripts\XOT-Uzg.v3\resources\libs\logger.py", line 119, in CleanUpLog
18:51:20 T:4452 M:2145390592  NOTICE:     os.remove(_oldFileName)
18:51:20 T:4452 M:2145390592  NOTICE: OSError: [Errno 22] Invalid argument: 'special://home/scripts/XOT-Uzg.v3/uzg.old.log'
So it seems that the 'os' library cannot handle the new special:// tags. Are there any work arounds?
Reply
#23
its probably because the special:// cmds haven't been back merged to xbox yet.

You need to put translatePath() around anything that uses os.

but, as translatePath() converts mappings to the new special:// equiv. I'd recommend sticking with Q: T: etc for now for wider platform compatibility.

BBB
Retired from Add-on dev
Reply
#24
BigBellyBilly Wrote:its probably because the special:// cmds haven't been back merged to xbox yet.

You need to put translatePath() around anything that uses os.

but, as translatePath() converts mappings to the new special:// equiv. I'd recommend sticking with Q: T: etc for now for wider platform compatibility.

BBB

I am doing this on XBMC Win32 and Linux
Reply
#25
@Basje: you need to do a os.remove(translatePath(_oldFileName)) for it to work.

as soon as you are accessing the filesystem with python itself and not using xbmc's functions, then you need to supply translatePath()
Reply
#26
translatePath() does NOT convert anything to special://.

It converts FROM special:// (or the old paths, which should ideally not be used) to the actual raw path that the OS should accept. Use translatePath() prior to calling any os command.

See my dev blog for more information:

http://xbmc.org/jmarshall/

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#27
jmarshall Wrote:translatePath() does NOT convert anything to special://.

It converts FROM special:// (or the old paths, which should ideally not be used) to the actual raw path that the OS should accept. Use translatePath() prior to calling any os command.

See my dev blog for more information:

http://xbmc.org/jmarshall/

Cheers,
Jonathan

I read that, but there you write:

Quote:Note that xbmc.translatePath() will take care of number 1 for you in the meantime, but this functionality is not guaranteed to be available forever.

So I thought that the translatePath() method would not be there for ever?
Reply
#28
I think he's referring to the backwards compatibility translation done in the func, not the removal of the func itself.
Retired from Add-on dev
Reply
#29
I was looking at Apple Movie Trailer II script which works on windows but doesn't work on linux. I changed the the following line in xbmcplugin_trailers.py:

Code:
BASE_DATA_PATH = os.path.join( xbmc.translatePath( "P:\\plugin_data" ), "video", sys.modules[ "__main__" ].__plugin__ )
    BASE_CURRENT_SOURCE_PATH = os.path.join( xbmc.translatePath( "P:\\plugin_data" ), "video", sys.modules[ "__main__" ].__plugin__, "current%s.xml" )

to the following

Code:
BASE_DATA_PATH = os.path.join( xbmc.translatePath( "special://profile/plugin_data" ), "video", sys.modules[ "__main__" ].__plugin__ )
    BASE_CURRENT_SOURCE_PATH = os.path.join( xbmc.translatePath( "special://profile/plugin_data" ), "video", sys.modules[ "__main__" ].__plugin__, "current%s.xml" )

And tested on linux ... It still doesn't work but in windows it works fine .. Now Finally I changed special://profile to special://masterprofile and now it works on linux..

Any reason behind this ?

special://masterprofile is mapping at the beggining in the logs but special://profile is done later on to special://masterprofile.
Reply
#30
You shouldn't need any of those changes, and the special://profile/ change should certainly function (they're essentially identical). What version are you running? Do you even use different profiles?

And there's a reason it's not in CSpecialProtocol::LogPaths() - it's not setup at that point (the path is mapped in CSettings::LoadProfile()) which comes a bit further down.)

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply

Logout Mark Read Team Forum Stats Members Help
special:// paths and translatePath0