Changeset 143
- Timestamp:
- 07/30/08 22:42:16 (16 years ago)
- Files:
-
- trunk/source/pyhesiodfs/pyHesiodFS.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/source/pyhesiodfs/pyHesiodFS.py
r142 r143 16 16 import hesiod 17 17 18 if not hasattr(fuse, '__version__'): 19 raise RuntimeError, \ 20 "your fuse-py doesn't know of fuse.__version__, probably it's too old." 18 new_fuse = hasattr(fuse, '__version__') 21 19 22 20 fuse.fuse_python_api = (0, 2) … … 28 26 If you're using the Finder, try pressing Cmd+Shift+G and then entering 29 27 %(mountpoint)s/name""" 28 29 if not hasattr(fuse, 'Stat'): 30 fuse.Stat = object 30 31 31 32 class MyStat(fuse.Stat): … … 42 43 self.st_ctime = 0 43 44 45 def toTuple(self): 46 return (self.st_mode, self.st_ino, self.st_dev, self.st_nlink, 47 self.st_uid, self.st_gid, self.st_size, self.st_atime, 48 self.st_mtime, self.st_ctime) 49 44 50 class PyHesiodFS(Fuse): 45 51 46 52 def __init__(self, *args, **kwargs): 47 53 Fuse.__init__(self, *args, **kwargs) 48 self.fuse_args.add("allow_other", True) 49 self.fuse_args.add("fsname", "pyHesiodFS") 54 try: 55 self.fuse_args.add("allow_other", True) 56 except AttributeError: 57 self.allow_other = 1 58 50 59 if sys.platform == 'darwin': 51 60 self.fuse_args.add("noappledouble", True) 52 61 self.fuse_args.add("noapplexattr", True) 53 62 self.fuse_args.add("volname", "MIT") 63 self.fuse_args.add("fsname", "pyHesiodFS") 54 64 self.mounts = {} 55 65 … … 72 82 else: 73 83 return -errno.ENOENT 74 return st 84 if new_fuse: 85 return st 86 else: 87 return st.toTuple() 75 88 76 89 def getCachedLockers(self): … … 98 111 return None 99 112 113 def getdir(self, path): 114 return [(i, 0) for i in (['.', '..', hello_path[1:]] + self.getCachedLockers())] 115 100 116 def readdir(self, path, offset): 101 for r in ['.', '..', hello_path[1:]]+self.getCachedLockers():117 for (r, zero) in self.getdir(path): 102 118 yield fuse.Direntry(r) 103 119 … … 126 142 def main(): 127 143 global hello_str 128 usage=""" 129 pyHesiodFS 144 try: 145 usage = Fuse.fusage 146 server = PyHesiodFS(version="%prog " + fuse.__version__, 147 usage=usage, 148 dash_s_do='setsingle') 149 server.parse(errex=1) 150 except AttributeError: 151 usage=""" 152 pyHesiodFS [mountpath] [options] 130 153 131 """ + Fuse.fusage132 server = PyHesiodFS(version="%prog " + fuse.__version__,133 usage=usage,134 dash_s_do='setsingle')154 """ 155 if sys.argv[1] == '-f': 156 sys.argv.pop(1) 157 server = PyHesiodFS() 135 158 136 server.parse(errex=1)137 159 hello_str = hello_str % {'mountpoint': server.parse(errex=1).mountpoint} 138 160 server.main()