示例#1
0
class repowatcher(server.repowatcher, pollable):
    """
    Watches inotify events
    """
    mask = (inotify.IN_ATTRIB | inotify.IN_CREATE | inotify.IN_DELETE
            | inotify.IN_DELETE_SELF | inotify.IN_MODIFY
            | inotify.IN_MOVED_FROM | inotify.IN_MOVED_TO
            | inotify.IN_MOVE_SELF | inotify.IN_ONLYDIR | inotify.IN_UNMOUNT
            | 0)

    def __init__(self, ui, dirstate, root):
        server.repowatcher.__init__(self, ui, dirstate, root)

        self.lastevent = {}
        self.dirty = False
        try:
            self.watcher = watcher.watcher()
        except OSError, err:
            raise util.Abort(
                _('inotify service not available: %s') % err.strerror)
        self.threshold = watcher.threshold(self.watcher)
        self.fileno = self.watcher.fileno
        self.register(timeout=None)

        self.handle_timeout()
        self.scan()
示例#2
0
文件: server.py 项目: as/9front-work
class repowatcher(pollable):
    """
    Watches inotify events
    """
    statuskeys = 'almr!?'
    mask = (inotify.IN_ATTRIB | inotify.IN_CREATE | inotify.IN_DELETE
            | inotify.IN_DELETE_SELF | inotify.IN_MODIFY
            | inotify.IN_MOVED_FROM | inotify.IN_MOVED_TO
            | inotify.IN_MOVE_SELF | inotify.IN_ONLYDIR | inotify.IN_UNMOUNT
            | 0)

    def __init__(self, ui, dirstate, root):
        self.ui = ui
        self.dirstate = dirstate

        self.wprefix = join(root, '')
        self.prefixlen = len(self.wprefix)
        try:
            self.watcher = watcher.watcher()
        except OSError, err:
            raise util.Abort(
                _('inotify service not available: %s') % err.strerror)
        self.threshold = watcher.threshold(self.watcher)
        self.fileno = self.watcher.fileno

        self.tree = directory()
        self.statcache = {}
        self.statustrees = dict([(s, directory()) for s in self.statuskeys])

        self.last_event = None

        self.lastevent = {}

        self.register(timeout=None)

        self.ds_info = self.dirstate_info()
        self.handle_timeout()
        self.scan()