def __init__(self, instance=os, root='.'): FileSystem.__init__(self, instance) self.root = os.path.normpath(root) self.eventQueue = EventQueue() self.eventHandler = EventHandler(self.eventQueue) self.observer = Observer() self.observer.schedule(self.eventHandler, path=self.root, recursive=True) self.observer.start()
def __init__(self, instance=os, root="."): FileSystem.__init__(self, instance) self.root = os.path.normpath(root) self.eventQueue = EventQueue() self.eventHandler = EventHandler(self.eventQueue) self.observer = Observer() self.observer.schedule(self.eventHandler, path=self.root, recursive=True) self.observer.start()
class OSFileSystem(FileSystem): """ This class represents a file system implemented by the python os module. """ def __init__(self, instance=os, root='.'): FileSystem.__init__(self, instance) self.root = os.path.normpath(root) self.eventQueue = EventQueue() self.eventHandler = EventHandler(self.eventQueue) self.observer = Observer() self.observer.schedule(self.eventHandler, path=self.root, recursive=True) self.observer.start() def join_path(self, path, *largs): return os.path.join(path, *largs) def get_relative_path(self, path): if path.startswith(self.root): return path.split(self.root + os.path.sep, 1)[1] else: return path def open(self, path, mode='rb', buffering=None): return open(path, mode) def mkdirs(self, path, mode=511): return os.makedirs(path, mode) def blockchecksums(self, path): return blockchecksums(path) def delta(self, path, checksums): return delta(path, checksums) def patch(self, path, delta): patched = patch(path, delta) self.instance.remove(path) return self.instance.rename(patched, path) def poll(self): r = [] while True: try: r.append(self.eventQueue.get_nowait()) except Empty: break return r
class OSFileSystem(FileSystem): """ This class represents a file system implemented by the python os module. """ def __init__(self, instance=os, root="."): FileSystem.__init__(self, instance) self.root = os.path.normpath(root) self.eventQueue = EventQueue() self.eventHandler = EventHandler(self.eventQueue) self.observer = Observer() self.observer.schedule(self.eventHandler, path=self.root, recursive=True) self.observer.start() def join_path(self, path, *largs): return os.path.join(path, *largs) def get_relative_path(self, path): if path.startswith(self.root): return path.split(self.root + os.path.sep, 1)[1] else: return path def open(self, path, mode="rb", buffering=None): return open(path, mode) def mkdirs(self, path, mode=511): return os.makedirs(path, mode) def blockchecksums(self, path): return blockchecksums(path) def delta(self, path, checksums): return delta(path, checksums) def patch(self, path, delta): patched = patch(path, delta) self.instance.remove(path) return self.instance.rename(patched, path) def poll(self): r = [] while True: try: r.append(self.eventQueue.get_nowait()) except Empty: break return r
def __init__(self, root, userkey, salt): """ Create a new server that handles the public key authentication. @param root: root path of the server. @type root: str @param userkey: path to the user's public key. @type userkey: str """ super(Server, self).__init__() self.root = root self.userkey = userkey self.salt = salt self.eventQueue = EventQueue() self.eventHandler = EventHandler(self.eventQueue) self.observer = Observer() self.observer.schedule(self.eventHandler, path=self.root, recursive=True) self.observer.start()