Kodi Community Forum
Changes to xbmcvfs.exists? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Changes to xbmcvfs.exists? (/showthread.php?tid=170887)



Changes to xbmcvfs.exists? - bossanova808 - 2013-08-09

Have there been any changes to VFSExists for Gotham...? I have some simple code and it's working on Alpha6 on my Windows boxes but a user in linux is reporting an issue. Code is really simply, and there are slashes at the end of the paths as I believe is required.

Basically it is this:
Code:
#strings to store the paths we will use
        RADAR_BACKGROUNDS_PATH = xbmc.translatePath("special://profile/addon_data/weather.ozweather/radarbackgrounds/" + radarCode + "/");
        LOOP_IMAGES_PATH = xbmc.translatePath("special://profile/addon_data/weather.ozweather/currentloop/" + radarCode + "/");

    #we need make the directories to store stuff if they don't exist
    if not xbmcvfs.exists( RADAR_BACKGROUNDS_PATH ):
        os.makedirs( RADAR_BACKGROUNDS_PATH )
    if not xbmcvfs.exists( LOOP_IMAGES_PATH ):
        os.makedirs( LOOP_IMAGES_PATH )

Gives an error:

Code:
20:59:58 T:139959354103552 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.OSError'>
Error Contents: (17, 'File exists', '/home/xbmc/.xbmc/userdata/addon_data/weather.ozweather/currentloop/IDR021/')
Traceback (most recent call last):
File "/home/xbmc/.xbmc/addons/weather.ozweather/default.py", line 578, in <module>
forecast(location, radar)
File "/home/xbmc/.xbmc/addons/weather.ozweather/default.py", line 167, in forecast
buildImages(radarCode)
File "/home/xbmc/.xbmc/addons/weather.ozweather/default.py", line 289, in buildImages
os.makedirs( LOOP_IMAGES_PATH )
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: (17, 'File exists', '/home/xbmc/.xbmc/userdata/addon_data/weather.ozweather/currentloop/IDR021/')

...but has een working for years fine on all platforms before this. .exists() is returning false but then the file exists, so it raises en exception. Obiviously I can try in a try/except but I think there might e a bug here?

Anyone else having any issues with Gotham Alpha 6??


RE: Changes to xbmcvfs.exists? - bossanova808 - 2014-01-16

I am pretty sure there are bugs in xbmcvfs.exists

...if I use it, it fails on directories that do exist, but if I substitute os.path.exists, the code works as expected.

If anyone is interested I can give more details but for now I am moving to os.path.exists as it's more reliable.


RE: Changes to xbmcvfs.exists? - sphere - 2014-01-17

The big (and only?) advantage of using "xbmcvfs" in favor of "os" is the possibility of using xbmc special filesystem-paths (plugin://, smb://, ...). I guess this is something you don't need so no need for xbmcvfs in that case.

Anyway, creating a ticket on track would be fine.


Re: RE: Changes to xbmcvfs.exists? - Martijn - 2014-01-17

(2014-01-17, 19:56)sphere Wrote: The big (and only?) advantage of using "xbmcvfs" in favor of "os" is the possibility of using xbmc special filesystem-paths (plugin://, smb://, ...). I guess this is something you don't need so no need for xbmcvfs in that case.

Anyway, creating a ticket on track would be fine.

And smb:// support amongst things that os doesn't support


RE: Changes to xbmcvfs.exists? - bossanova808 - 2014-01-17

OK will trak it soon. This is just a straight windows path constructed above it using translatepath()


RE: Changes to xbmcvfs.exists? - Bstrdsmkr - 2014-01-17

ATV can't Mount network locations so xbmcvfs is the only way to accomplish writing to network locations on that platform


RE: Changes to xbmcvfs.exists? - ronie - 2014-01-18

(2014-01-16, 03:59)bossanova808 Wrote: If anyone is interested I can give more details but for now I am moving to os.path.exists as it's more reliable.

more details please. as usual, a full Debug Log wouldn't hurt. :-)

i've tested the code in your first post and it runs fine on linux.


RE: Changes to xbmcvfs.exists? - bossanova808 - 2014-01-18

hmmm I think it's a known issues with shuti.rmtree returning before it has actually deleted a directory, and then my code trying to make it again...apparenyly a known thing due to async rmtree.

I'll look into it further but it's more like a general python thing I think