Skip to content

xbmcvfs extend #1013

Merged
merged 3 commits into from Jun 2, 2012

7 participants

@amet
amet commented May 25, 2012

repeat of #36 from about a year ago.

extends xbmcvfs functionality and removes SubtitleFileSizeAndHash as its not needed anymore.

Cheers,
amet

@jmarshallnz
Team Kodi member

I think we need to discuss whether we want open slather, or whether we want to permission this somehow.

Not sure the best way to handle the permissions, but it seems reasonable to me that at the very least the user is informed that add-on X has the ability to read your filesystem or that add-on X has the ability to write to your filesystem (delete in this case).

@MartijnKaijser
Team Kodi member

perhaps a setting that the needs to set to give that add-on explicit permission?

@alcoheca

+1 on permissions and user's being informed on this. Without a permissions orientated API inplace, you could simulate this using modification to the addon.xml schema (only addons which explicitly require this portion of the xbmc api are allowed access), and a little bit of glue code in addons installer (notifications) and in the vfs module (check against addons db for permission?).

it might seem like work now, but it's beneficial in the long run

@amet
amet commented May 26, 2012

@jmarshallnz this is no different than what python does right now. this just mimics that behavior ... same would apply for any python module then

@jmarshallnz
Team Kodi member

Python has access only locally by default, however. It doesn't have access to non-local files, right?

@PatFrost

wow good extend :)

@amet , Possible to create super-mkdir function. same as os.makedirs

"""makedirs(path)

Super-mkdir; create a leaf directory and all intermediate ones.
Works like mkdir, except that any intermediate path segment (not
just the rightmost) will be created if it does not exist.  This is
recursive.

"""

@PatFrost

great :)
but not work, error is start with / and not sure but don't check and create root folder G:

"""
20:23:25 T:6624 ERROR: XFILE::CDirectory::Create - Error creating /G:
20:23:25 T:6624 ERROR: XFILE::CDirectory::Create - Error creating /G:/pydocs
20:23:25 T:6624 ERROR: XFILE::CDirectory::Create - Error creating /G:/pydocs/xbmc
20:23:25 T:6624 ERROR: An error occurred saving xbmcvfs! ([Errno 2] No such file or directory: 'G:\pydocs\xbmc\xbmcvfs.html')
"""

same with ftp or smb

"""
20:35:40 T:7856 WARNING: XFILE::CDirectoryFactory::Create - Unsupported protocol(/smb) in /smb://---/
20:35:40 T:7856 ERROR: XFILE::CDirectory::Exists - Error checking for /smb://---/
20:35:40 T:7856 WARNING: XFILE::CDirectoryFactory::Create - Unsupported protocol(/smb) in /smb://----/Medias/pydocs
20:35:40 T:7856 ERROR: XFILE::CDirectory::Create - Error creating /smb://----//Medias/pydocs

20:27:18 T:7392 WARNING: XFILE::CDirectoryFactory::Create - Unsupported protocol(/ftp) in /ftp://xbox:xbox@192.168.0.2:21/
20:27:18 T:7392 ERROR: XFILE::CDirectory::Exists - Error checking for /ftp://xbox:xbox@192.168.0.2:21/
20:27:18 T:7392 WARNING: XFILE::CDirectoryFactory::Create - Unsupported protocol(/ftp) in /ftp://xbox:xbox@192.168.0.2:21/G/WebDownload/pydocs
20:27:18 T:7392 ERROR: XFILE::CDirectory::Exists - Error checking for /ftp://xbox:xbox@192.168.0.2:21/G/WebDownload/pydocs
"""

@amet
amet commented May 27, 2012

@PatFrost please try now

@PatFrost

hi amet,

yes it's ok with smb and local location. tested mkdirs, listdir, and File(...).read()
Not work with FTP, others functions work with FTP copy, delete, exists etc...

FTP mkdirs
09:16:35 T:6876 ERROR: CUtil::CreateDirectoryExA called with an unsupported path: ftp://xbox:xbox@192.168.0.2:21/G/WebDownload/pydocs/xbmc

FTP listdir
09:16:35 T:6876 ERROR: XFILE::CDirectory::GetDirectory - Error getting ftp://xbox:xbox@192.168.0.2:21/G/WebDownload/pydocs/xbmc
09:16:35 T:6876 NOTICE: ([], [])


Others request :) possible to add write file

f = xbmcvfs.File(_path)
f.write( "foo" )
f.close()

good job amet
frost

@amet
amet commented May 27, 2012

@PatFrost FTP is read only on XBMC, at least it should be :)

EDIT: see here -> https://github.com/xbmc/xbmc/blob/master/xbmc/Util.cpp#L1182 it only allows for local, SMB/NFS/AFP files... no FTP

@amet
amet commented May 27, 2012

@PatFrost check again, write should be ok.

@PatFrost

FTP is read only! ok but xbmcvfs.delete(...) deleted a dummy file on my xbox :D I retest tomorrow


:) it's ok for write on smb share

f = xbmcvfs.File( _path, "w" )
print f.write( doc.document( eval( module ) ) )
f.close()

result : http://passion-xbmc.org/gros_fichiers/frost/xbmcvfs.html

Thanks amet
I will back tomorrow for more test...
Frost

@amet
amet commented May 28, 2012

@PatFrost for some reason mkdirs is limited to the above mentioned protocols, FTP is not one of them unfortunately. I am not sure why, but I am sure there is a valid reason for it :)

@jmarshallnz
Team Kodi member

Looks ok other than that one minor comment issue.

@amet amet merged commit 5a0237b into xbmc:master Jun 2, 2012
@twinther
twinther commented Jun 6, 2012

Hi @amet
I know you already pulled this, but it would be really great to have stat() included as well.
This would solve some problems for me in my TV Guide addon.
Also this feature request in trac can be closed.. http://trac.xbmc.org/ticket/12849

Br.
Tommy

@theuni

@amet: I segfault unless I also add InitVFSTypes(); to XBPython::InitializeInterpreter. It was a blind c/p, so I have no idea what's going on there. But from the looks, it's safe to assume that's needed?

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.