Index: trunk/source/pyhesiodfs/pyHesiodFS.py =================================================================== --- trunk/source/pyhesiodfs/pyHesiodFS.py (revision 142) +++ trunk/source/pyhesiodfs/pyHesiodFS.py (revision 143) @@ -16,7 +16,5 @@ import hesiod -if not hasattr(fuse, '__version__'): - raise RuntimeError, \ - "your fuse-py doesn't know of fuse.__version__, probably it's too old." +new_fuse = hasattr(fuse, '__version__') fuse.fuse_python_api = (0, 2) @@ -28,4 +26,7 @@ If you're using the Finder, try pressing Cmd+Shift+G and then entering %(mountpoint)s/name""" + +if not hasattr(fuse, 'Stat'): + fuse.Stat = object class MyStat(fuse.Stat): @@ -42,14 +43,23 @@ self.st_ctime = 0 + def toTuple(self): + return (self.st_mode, self.st_ino, self.st_dev, self.st_nlink, + self.st_uid, self.st_gid, self.st_size, self.st_atime, + self.st_mtime, self.st_ctime) + class PyHesiodFS(Fuse): def __init__(self, *args, **kwargs): Fuse.__init__(self, *args, **kwargs) - self.fuse_args.add("allow_other", True) - self.fuse_args.add("fsname", "pyHesiodFS") + try: + self.fuse_args.add("allow_other", True) + except AttributeError: + self.allow_other = 1 + if sys.platform == 'darwin': self.fuse_args.add("noappledouble", True) self.fuse_args.add("noapplexattr", True) self.fuse_args.add("volname", "MIT") + self.fuse_args.add("fsname", "pyHesiodFS") self.mounts = {} @@ -72,5 +82,8 @@ else: return -errno.ENOENT - return st + if new_fuse: + return st + else: + return st.toTuple() def getCachedLockers(self): @@ -98,6 +111,9 @@ return None + def getdir(self, path): + return [(i, 0) for i in (['.', '..', hello_path[1:]] + self.getCachedLockers())] + def readdir(self, path, offset): - for r in ['.', '..', hello_path[1:]]+self.getCachedLockers(): + for (r, zero) in self.getdir(path): yield fuse.Direntry(r) @@ -126,13 +142,19 @@ def main(): global hello_str - usage=""" -pyHesiodFS + try: + usage = Fuse.fusage + server = PyHesiodFS(version="%prog " + fuse.__version__, + usage=usage, + dash_s_do='setsingle') + server.parse(errex=1) + except AttributeError: + usage=""" +pyHesiodFS [mountpath] [options] -""" + Fuse.fusage - server = PyHesiodFS(version="%prog " + fuse.__version__, - usage=usage, - dash_s_do='setsingle') +""" + if sys.argv[1] == '-f': + sys.argv.pop(1) + server = PyHesiodFS() - server.parse(errex=1) hello_str = hello_str % {'mountpoint': server.parse(errex=1).mountpoint} server.main()