| Trees | Indices | Help |
|---|
|
|
1 # -*- Mode: Python -*- 2 # vi:si:et:sw=4:sts=4:ts=4 3 # 4 # Flumotion - a streaming media server 5 # Copyright (C) 2008 Fluendo, S.L. (www.fluendo.com). 6 # All rights reserved. 7 8 # This file may be distributed and/or modified under the terms of 9 # the GNU General Public License version 2 as published by 10 # the Free Software Foundation. 11 # This file is distributed without any warranty; without even the implied 12 # warranty of merchantability or fitness for a particular purpose. 13 # See "LICENSE.GPL" in the source distribution for more information. 14 15 # Licensees having purchased or holding a valid Flumotion Advanced 16 # Streaming Server license may use this file in accordance with the 17 # Flumotion Advanced Streaming Server Commercial License Agreement. 18 # See "LICENSE.Flumotion" in the source distribution for more information. 19 20 # Headers in this file shall remain intact. 21 22 """GnomeVFS backend for Virtual File System. 23 """ 24 25 import os 26 27 from twisted.internet.defer import succeed 28 from twisted.spread.flavors import Copyable, RemoteCopy 29 from twisted.spread.jelly import setUnjellyableForClass 30 from zope.interface import implements 31 32 from flumotion.common import log 33 from flumotion.common.errors import AccessDeniedError 34 from flumotion.common.interfaces import IDirectory, IFile 35 36 # gnomevfs is only imported inside nested scopes so that 37 # pychecker can ignore them, If pychecker ever gets fixed, 38 # move it back where it belongs 39 __pychecker__ = 'keepgoing' 40 4143 """I am object implementing L{IFile} on top of GnomeVFS, 44 see L{IFile} for more information. 45 """ 46 implements(IFile) 47 52 53 # IFile 5457 5860 """I am object implementing L{IDirectory} on top of GnomeVFS, 61 see L{IDirectory} for more information. 62 """ 63 implements(IDirectory) 6499 10066 import gnomevfs 67 fileInfo = gnomevfs.get_file_info(os.path.abspath(path)) 68 self.path = path 69 self.filename = fileInfo.name 70 self.iconNames = ['gnome-fs-directory']71 72 # IFile 7375 return self.path76 77 # IDirectory 7880 import gnomevfs 81 log.info('vfsgnome', 'getting files for %s' % (self.path,)) 82 retval = [] 83 try: 84 fileInfos = gnomevfs.open_directory(self.path) 85 except gnomevfs.AccessDeniedError: 86 raise AccessDeniedError 87 for fileInfo in fileInfos: 88 filename = fileInfo.name 89 if filename.startswith('.') and filename != '..': 90 continue 91 if fileInfo.type == gnomevfs.FILE_TYPE_DIRECTORY: 92 obj = GnomeVFSDirectory(os.path.join(self.path, 93 fileInfo.name)) 94 else: 95 obj = GnomeVFSFile(self.path, fileInfo) 96 retval.append(obj) 97 log.info('vfsgnome', 'returning %r' % (retval,)) 98 return succeed(retval)102 """Register the jelly used by the GnomeVFS VFS backend. 103 """ 104 setUnjellyableForClass(GnomeVFSFile, GnomeVFSFile) 105 setUnjellyableForClass(GnomeVFSDirectory, GnomeVFSDirectory) 106 log.info('jelly', 'GnomeVFS registered')107
| Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Sat Jul 26 09:43:08 2008 | http://epydoc.sourceforge.net |