本文整理汇总了Python中pyinotify.IN_CLOSE_WRITE属性的典型用法代码示例。如果您正苦于以下问题:Python pyinotify.IN_CLOSE_WRITE属性的具体用法?Python pyinotify.IN_CLOSE_WRITE怎么用?Python pyinotify.IN_CLOSE_WRITE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pyinotify
的用法示例。
在下文中一共展示了pyinotify.IN_CLOSE_WRITE属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_IN_CLOSE_WRITE
# 需要导入模块: import pyinotify [as 别名]
# 或者: from pyinotify import IN_CLOSE_WRITE [as 别名]
def process_IN_CLOSE_WRITE(self, event):
global temps, channels, pitmaster, pitconf, Config, configfile
global temps_event, channels_event, pitmaster_event, pitconf_event, logger
logger.debug("IN_CLOSE_WRITE: %s " % os.path.join(event.path, event.name))
if event.path == curPath and event.name == curFile:
logger.debug(_(u'New temperature values available'))
temps_event.set()
elif event.path == confPath and event.name == confFile:
logger.debug(_(u'New configuration data available'))
channels_event.set()
pitconf_event.set()
config_event.set()
elif event.path == pitPath and event.name == pitFile:
logger.debug(_(u'New pitmaster data available'))
pitmaster_event.set()
elif event.path == pit2Path and event.name == pit2File:
logger.debug(_(u'New pitmaster data available'))
pitmaster2_event.set()
示例2: run
# 需要导入模块: import pyinotify [as 别名]
# 或者: from pyinotify import IN_CLOSE_WRITE [as 别名]
def run(self):
self.running = True
wm = pyinotify.WatchManager()
notifier = pyinotify.Notifier(wm)
def inotify_callback(event):
if event.mask == pyinotify.IN_CLOSE_WRITE:
self._parse_desktop_file(event.pathname)
elif event.mask == pyinotify.IN_DELETE:
with self.lock:
for cmd, data in self.apps.items():
if data[2] == event.pathname:
del self.apps[cmd]
break
for p in DESKTOP_PATHS:
if os.path.exists(p):
wm.add_watch(p,
pyinotify.IN_CLOSE_WRITE | pyinotify.IN_DELETE,
inotify_callback)
notifier.loop()
示例3: setup
# 需要导入模块: import pyinotify [as 别名]
# 或者: from pyinotify import IN_CLOSE_WRITE [as 别名]
def setup(self):
""" Set up inotify manager.
See https://github.com/seb-m/pyinotify/.
"""
if not pyinotify.WatchManager:
raise error.UserError("You need to install 'pyinotify' to use %s (%s)!" % (
self.__class__.__name__, pyinotify._import_error)) # pylint: disable=E1101, W0212
self.manager = pyinotify.WatchManager()
self.handler = TreeWatchHandler(job=self)
self.notifier = pyinotify.AsyncNotifier(self.manager, self.handler)
if self.LOG.isEnabledFor(logging.DEBUG):
mask = pyinotify.ALL_EVENTS
else:
mask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_MOVED_TO # bogus pylint: disable=E1101
# Add all configured base dirs
for path in self.config.path:
self.manager.add_watch(path.strip(), mask, rec=True, auto_add=True)
示例4: _loop_linux
# 需要导入模块: import pyinotify [as 别名]
# 或者: from pyinotify import IN_CLOSE_WRITE [as 别名]
def _loop_linux(self, loop_callback):
"""loop implementation for linux platform"""
import pyinotify
handler = self._handle
class EventHandler(pyinotify.ProcessEvent):
def process_default(self, event):
handler(event)
watch_manager = pyinotify.WatchManager()
event_handler = EventHandler()
notifier = pyinotify.Notifier(watch_manager, event_handler)
mask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_MOVED_TO
for watch_this in self.watch_dirs:
watch_manager.add_watch(watch_this, mask)
notifier.loop(loop_callback)
示例5: process_IN_CLOSE_WRITE
# 需要导入模块: import pyinotify [as 别名]
# 或者: from pyinotify import IN_CLOSE_WRITE [as 别名]
def process_IN_CLOSE_WRITE(self, event):
logger.debug("IN_CLOSE_WRITE: %s " % os.path.join(event.path, event.name))
show_values()
示例6: process_IN_CLOSE_WRITE
# 需要导入模块: import pyinotify [as 别名]
# 或者: from pyinotify import IN_CLOSE_WRITE [as 别名]
def process_IN_CLOSE_WRITE(self, event):
if (os.path.join(event.path, event.name) == "/var/www/conf/WLANThermo.conf"):
#print "IN_CLOSE_WRITE: %s " % os.path.join(event.path, event.name)
read_config()
示例7: process_default
# 需要导入模块: import pyinotify [as 别名]
# 或者: from pyinotify import IN_CLOSE_WRITE [as 别名]
def process_default(self, event):
""" for each incoming event: place route to run in a set. Main thread sends actual job.
"""
# ~ if event.mask == pyinotify.IN_CLOSE_WRITE and event.dir and self.watch_data[event.wd][2]:
# ~ logger.info(u'new directory!!"%s %s".',event.)
# ~ print 'event detected',event.name,event.maskname, event.wd
if not event.dir:
for dir_watch in self.dir_watch_data:
if event.pathname.startswith(dir_watch['path']):
# if fnmatch.fnmatch(event.name, dir_watch['filemask']):
self.cond.acquire()
self.tasks.add((dir_watch['organization'], dir_watch['partner'], event.pathname))
self.cond.notify()
self.cond.release()
示例8: linux_event_handler
# 需要导入模块: import pyinotify [as 别名]
# 或者: from pyinotify import IN_CLOSE_WRITE [as 别名]
def linux_event_handler(logger, dir_watch_data, cond, tasks):
watch_manager = pyinotify.WatchManager()
mask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_MOVED_TO | pyinotify.IN_MODIFY | pyinotify.IN_CREATE
for dir_watch in dir_watch_data:
logger.info(_(u'Watching directory %s' % dir_watch['path']))
watch_manager.add_watch(path=dir_watch['path'], mask=mask, rec=False, auto_add=True, do_glob=True)
handler = LinuxEventHandler(logger=logger, dir_watch_data=dir_watch_data, cond=cond, tasks=tasks)
notifier = pyinotify.Notifier(watch_manager, handler)
notifier.loop()
# end of linux-specific ##################################################################################
示例9: watch_folder
# 需要导入模块: import pyinotify [as 别名]
# 或者: from pyinotify import IN_CLOSE_WRITE [as 别名]
def watch_folder(module, params):
log.debug('Watching folder %s for screenshots ...' % params['in'])
screen_wm = pyinotify.WatchManager()
screen_mask = pyinotify.IN_CLOSE_WRITE
screen_notifier = pyinotify.AsyncNotifier(screen_wm, ScreenshotHandler())
screen_wdd = screen_wm.add_watch(params['in'], screen_mask, rec = True)
asyncore.loop()
示例10: watch_folder
# 需要导入模块: import pyinotify [as 别名]
# 或者: from pyinotify import IN_CLOSE_WRITE [as 别名]
def watch_folder(properties):
log.debug('Function "folder" launched with params %s: ' % properties)
# inotify kernel watchdog stuff
wm = pyinotify.WatchManager()
mask = pyinotify.IN_CLOSE_WRITE
notifier = pyinotify.AsyncNotifier(wm, EventHandler())
wdd = wm.add_watch(properties['in'], mask, rec = True)
log.debug('watching :: %s' % properties['in'])
asyncore.loop()
示例11: watch
# 需要导入模块: import pyinotify [as 别名]
# 或者: from pyinotify import IN_CLOSE_WRITE [as 别名]
def watch(parent_id=None, mount=False):
"Watch a folder for new torrents to add"
if parent_id == None:
parent_id = app.config.get('PUTIO_ROOT', 0)
if mount and not os.path.exists(app.config['TORRENTS']):
subprocess.call([
'mount',
'-a'
])
add()
class EventHandler(pyinotify.ProcessEvent):
"Event handler for responding to a new or updated torrent file"
def process_IN_CLOSE_WRITE(self, event):
"Do the above"
app.logger.debug('adding torrent, received event: %s' % event)
transfer = app.client.Transfer.add_torrent(event.pathname, parent_id=parent_id)
os.unlink(event.pathname)
app.logger.info('added transfer: %s' % transfer)
watch_manager = pyinotify.WatchManager()
mask = pyinotify.IN_CLOSE_WRITE
handler = EventHandler()
notifier = pyinotify.Notifier(watch_manager, handler)
wdd = watch_manager.add_watch(app.config['TORRENTS'], mask, rec=True)
app.logger.debug('added watch: %s' % wdd)
notifier.loop()
示例12: main
# 需要导入模块: import pyinotify [as 别名]
# 或者: from pyinotify import IN_CLOSE_WRITE [as 别名]
def main(args_ns: argparse.Namespace) -> None:
tmpdir = tempfile.mkdtemp(prefix="rcrsv-gbstr") # directory for gobuster scan results
# watch manager stores the watches and provides operations on watches
wm = pyinotify.WatchManager()
version = get_gobuster_version()
handler = EventHandler(
target=args_ns.target,
tmpdir=tmpdir,
wordlist=args_ns.wordlist,
threads=args_ns.threads,
extensions=args_ns.extensions,
devnull=args.devnull,
user=args_ns.user,
password=args_ns.password,
proxy=args_ns.proxy,
version=version,
status=args_ns.status,
)
notifier = pyinotify.Notifier(wm, handler)
# watch for file appends (found dir/file) and files closing (scan complete)
mask = pyinotify.IN_MODIFY | pyinotify.IN_CLOSE_WRITE
wm.add_watch(tmpdir, mask)
handler.run_gobuster(args_ns.target) # kick off first scan against initial target
signal.signal(signal.SIGINT, handler.cleanup) # register signal handler to handle SIGINT
notifier.loop()