X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/python-routefs.git/blobdiff_plain/4909cd3c77813b3c61f26fd6af4f3a0958cc92f4..427878a7a692997d2be7dcfe8051673ec8ec7ba6:/routefs/examples/pyhesiodfs.py diff --git a/routefs/examples/pyhesiodfs.py b/routefs/examples/pyhesiodfs.py index 0a5aa3e..b3daa84 100755 --- a/routefs/examples/pyhesiodfs.py +++ b/routefs/examples/pyhesiodfs.py @@ -1,26 +1,31 @@ #!/usr/bin/python + import hesiod -import routefs from routes import Mapper +import routefs + + class PyHesiodFS(routefs.RouteFS): + controllers = ['getList', 'getReadme', 'getLocker'] def __init__(self, *args, **kwargs): super(PyHesiodFS, self).__init__(*args, **kwargs) - + self.fuse_args.add("allow_other", True) + self.cache = {} - + def make_map(self): m = Mapper() - m.connect('', controller='getList') - m.connect('README.txt', controller='getReadme') - m.connect(':action', controller='getLocker') + m.connect('/', controller='getList') + m.connect('/README.txt', controller='getReadme') + m.connect('/{action}', controller='getLocker') return m - + def getLocker(self, action, **kwargs): if action in self.cache: return routefs.Symlink(self.cache[action]) - + try: filsys = hesiod.FilsysLookup(action).filsys[0] if filsys['type'] == 'AFS': @@ -28,18 +33,19 @@ class PyHesiodFS(routefs.RouteFS): return routefs.Symlink(self.cache[action]) except (TypeError, KeyError, IndexError): return - + def getList(self, **kwargs): - return routefs.Directory(self.cache.keys() + ['README.txt']) - + return self.cache.keys() + ['README.txt'] + def getReadme(self, **kwargs): - return routefs.File(""" + return """ This is the pyHesiodFS FUSE automounter. To access a Hesiod filsys, just access /mit/name. If you're using the Finder, try pressing Cmd+Shift+G and then entering /mit/name -""") +""" + if __name__ == '__main__': routefs.main(PyHesiodFS)