当前位置: 首页>>代码示例>>Python>>正文


Python Notifier.add_watch方法代码示例

本文整理汇总了Python中pyinotify.Notifier.add_watch方法的典型用法代码示例。如果您正苦于以下问题:Python Notifier.add_watch方法的具体用法?Python Notifier.add_watch怎么用?Python Notifier.add_watch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyinotify.Notifier的用法示例。


在下文中一共展示了Notifier.add_watch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: WatchManager

# 需要导入模块: from pyinotify import Notifier [as 别名]
# 或者: from pyinotify.Notifier import add_watch [as 别名]
class WatchManager(watchdir):
	path = os.path.abspath(watchdir)				#path = list() ##(str or list of str): ## Path(s) to watch, the path can either be a file or a directory.
	add_watch(path, mask, proc_fun=None, rec=False, auto_add=False) = dict()		#=> dict
	mask(int) = int(mask) 							#Bitmask of events.
	proc_func(ProcessEvent) = proc_func 			###	Processing object (must be callable). Will be called if provided, otherwise, notifier.default_proc_funcwill be called.
	rec(bool) =  bool(rec) 							######	Recursively add watches on the given path and on all its subdirectories.
	auto_add(bool) = bool(auto_add) 				#	Automatically add watches on newly created directories in the watch's path.
	update_watch(wd, mask=None, proc_func=None, rec=False, auto_add=False) = update_watch		#=> dict
											#Update existing watch(s). All these parameters are updatable.
	rm_watch(wd, rec=False) = dict() #=> dict			#Remove watch(s).
	get_wd(path) 		#=> int						#Return the watch descriptor associated to path.
	get_path(wd) 		#=> str						#Return the path associated to wd, if wd is invalid, None is returned.
	return os.path.abspath(wd)



ra = notifier.add_watch('/a-dir', mask)
if ra['/a-dir'] > 0: print "added"


#update_watch wd (or list of wds) 	{wd1: success, wd2: success, ...}
	#Where success is True if the op on wdx succeeded, False otherwise.
ru = notifier.update_watch(ra['/a-dir'], new_mask)
if ru['/a-dir']: print "updated"


#rm_watch 	wd (or list of wds) 	{wd1: success, wd2: success, ...}
	#Where success is True if the op on wdx succeeded, False otherwise.
rr = notifier.rm_watch(ra['/a-dir'])
if rr['/a-dir']: print "deleted"
开发者ID:relic7,项目名称:prodimages,代码行数:32,代码来源:DirWatchManager.py


注:本文中的pyinotify.Notifier.add_watch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。