1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
37
38
39 __pychecker__ = 'keepgoing'
40
41
43 """I am object implementing L{IFile} on top of GnomeVFS,
44 see L{IFile} for more information.
45 """
46 implements(IFile)
47
52
53
54
56 return os.path.join(self.parent, self.filename)
57
58
60 """I am object implementing L{IDirectory} on top of GnomeVFS,
61 see L{IDirectory} for more information.
62 """
63 implements(IDirectory)
64
66 import gnomevfs
67 if not os.path.exists(path):
68 self.path = '/'
69 else:
70 self.path = os.path.abspath(path)
71
72 if name is None:
73 fileInfo = gnomevfs.get_file_info(self.path)
74 name = fileInfo.name
75 self.filename = name
76 self.iconNames = ['gnome-fs-directory']
77 self._cachedFiles = None
78
79
80
83
84
85
87 return succeed(self._cachedFiles)
88
90 """
91 Fetches the files contained on the directory for posterior usage of
92 them. This should be called on the worker side to work or the files
93 wouldn't be the expected ones.
94 """
95 import gnomevfs
96 log.debug('vfsgnome', 'getting files for %s' % (self.path, ))
97 retval = []
98 try:
99 fileInfos = gnomevfs.open_directory(self.path)
100 except gnomevfs.AccessDeniedError:
101 raise AccessDeniedError
102 if self.path != '/':
103 retval.append(GnomeVFSDirectory(os.path.dirname(self.path),
104 name='..'))
105 for fileInfo in fileInfos:
106 filename = fileInfo.name
107 if filename.startswith('.'):
108 continue
109 if fileInfo.type == gnomevfs.FILE_TYPE_DIRECTORY:
110 obj = GnomeVFSDirectory(os.path.join(self.path,
111 fileInfo.name))
112 else:
113 obj = GnomeVFSFile(self.path, fileInfo)
114 retval.append(obj)
115 log.log('vfsgnome', 'returning %r' % (retval, ))
116 self._cachedFiles = retval
117
118
125