Make naming consistent with tree_watcher

This commit is contained in:
ZyX 2014-06-28 22:37:05 +04:00
parent 61074fcd6c
commit 14608d1bf9
3 changed files with 10 additions and 10 deletions

View File

@ -3,8 +3,8 @@ from __future__ import unicode_literals, absolute_import
import sys
from powerline.lib.watcher.stat import StatWatch
from powerline.lib.watcher.inotify import INotifyWatch, INotifyError
from powerline.lib.watcher.stat import StatFileWatcher
from powerline.lib.watcher.inotify import INotifyFileWatcher, INotifyError
def create_file_watcher(pl, watcher_type='auto', expire_time=10):
@ -32,18 +32,18 @@ def create_file_watcher(pl, watcher_type='auto', expire_time=10):
'''
if watcher_type == 'stat':
pl.debug('Using requested stat-based watcher', prefix='watcher')
return StatWatch()
return StatFileWatcher()
if watcher_type == 'inotify':
# Explicitly selected inotify watcher: do not catch INotifyError then.
pl.debug('Using requested inotify watcher', prefix='watcher')
return INotifyWatch(expire_time=expire_time)
return INotifyFileWatcher(expire_time=expire_time)
if sys.platform.startswith('linux'):
try:
pl.debug('Trying to use inotify watcher', prefix='watcher')
return INotifyWatch(expire_time=expire_time)
return INotifyFileWatcher(expire_time=expire_time)
except INotifyError:
pl.info('Failed to create inotify watcher', prefix='watcher')
pl.debug('Using stat-based watcher')
return StatWatch()
return StatFileWatcher()

View File

@ -11,9 +11,9 @@ from powerline.lib.monotonic import monotonic
from powerline.lib.path import realpath
class INotifyWatch(INotify):
class INotifyFileWatcher(INotify):
def __init__(self, expire_time=10):
super(INotifyWatch, self).__init__()
super(INotifyFileWatcher, self).__init__()
self.watches = {}
self.modified = {}
self.last_query = {}
@ -134,4 +134,4 @@ class INotifyWatch(INotify):
self.unwatch(path)
except OSError:
pass
super(INotifyWatch, self).close()
super(INotifyFileWatcher, self).close()

View File

@ -8,7 +8,7 @@ from threading import RLock
from powerline.lib.path import realpath
class StatWatch(object):
class StatFileWatcher(object):
def __init__(self):
self.watches = {}
self.lock = RLock()