Skip to content

xbmcvfs addition #71

Merged
1 commit merged into from Mar 16, 2011

4 participants

@amet
amet commented Mar 16, 2011

here is a simple addition to xbmcvfs python module, checks for file or folder existence. needed on external python builds and smb://, among others

@ghost
ghost commented Mar 16, 2011

same comment as last time - we should mimic stdio. however, we can change that later so no objections on this going in for now.

@lucianm lucianm pushed a commit that referenced this pull request Apr 28, 2011
@opdenkamp opdenkamp Merged pull request #71 from pipelka/pvr-recordingslist-fix.
pvr: fix recordings list. display recordings if there are subdirectories
a113387
@queeup

Hmm it return just "1". Should be true? Also one question: Why return string? I guess better return "True" for python.

Team Kodi member

Are you sure that this line returns "1"? Because the code says if the parameter passed to vfs_exists() is not a valid python string/unicode object it will return NULL which will probably end in an exception being thrown.

Yea I test it one of my add-on like this: print 'exsist: %s' % xbmcvfs.exists(xbmc.translatePath(cachedir))
and it print to log this: NOTICE: exsist: 1

Maybe I am on wrong line but something return "1".

@queeup

Same here, maybe you can consider return "False" instead string "false"

Team Kodi member

This line doesn't return anything either. It just stores the result of the actual Exists() call in bResult. The generation of the actual python object that will be returned happens on line 203 (4 lines further down).

Sorry I don't know actually. But you get the point right?

amet replied Jan 29, 2012

line 202 returns bool bResult to the addon(True/False) and is constructed as bool

Team Kodi member

According to the Python API for Py_BuildValue (see http://docs.python.org/c-api/arg.html#Py_BuildValue) the "b" in Py_BuildValue actually does not result in a boolean (True/False) but in an integer (from a character). Doesn't look like Py_BuildValue() has a way of returning the python objects True or False. That would have to be done using something like

if (bResult)
  Py_RETURN_TRUE;
else
  Py_RETURN_FALSE;
amet replied Jan 29, 2012

ok, fair ...

if xbmcvfs.exists(xbmc.translatePath(cachedir)):
    print "exists"
else:
    print "doesnt exist"

would still work

How is that possible?

print xbmcvfs.exists(xbmc.translatePath(cachedir)) return integer (1/0) not a boolean (True/False)

Team Kodi member

I use it that way and it works

if xbmcvfs.exists(path):
do something

amet replied Jan 29, 2012

@queeup

it works, try it ...

Confirmed. You are right it's working. Sorry for disturbed you guys.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.