提供用于生成文件监视程序的框架。包括一个文件监视程序实用程序,允许您以声明方式创建文件监视程序。
noticeme的Python项目详细描述
注意事项
为inotify提供python绑定,并为使用协程构建文件监视程序提供框架。
请注意,这只在linux上运行,a没有计划支持任何其他操作系统。
不过,还有很多选择。
noticeme包括noticeme命令,用于快速设置文件监视程序。
以声明方式使用noticeme
如果你只需要一个小的文件观察程序,你可以试试这个
pip install --user noticeme # install
nano noticeme.cfg # use noticeme/examples/noticeme.cfg for an example
noticeme # start watching
要查看事件的完整列表:
noticeme events
要选择要运行的监视程序,可以提供一个列表。
假设我们有一个名为build:js、build:css的观察程序,并且在一个配置文件中进行测试。
在一个终端中,我们可以运行:
noticeme build:js build:css
在另一个:
noticeme test
快速查看配置
有关详细信息,请参见noticeme/examples/noticeme.cfg
# noticeme.cfg
[should]
clear_screen = yes
[imports]
example = A .py file with a @noticeme.watcher decorator in it
[my_watcher]
description = This is an example.
paths = . **
events = written
regex = ^docs
glob = *.txt
shell = echo "my_watcher: file was added"
使用noticeme以编程方式构建文件监视程序
import asyncio
import noticeme
@noticeme.watcher('/path/to/directory', 'created modified')
async def my_watcher(event):
if '.py' == event.path.suffix.lower():
proc = await asyncio.create_subprocess_exec('cmd', event.path.absolute())
await proc.wait()
if __name__ == '__main__':
noticeme.run()
要求
- Linux=2.6.13
- python>;=3.5
- CFFI
- C编译器已安装(如果需要运行inotify_build.py)
安装
PIP
pip install --user noticeme
直接包含
- 将noticeme.py和inotify_build.py复制到项目目录
- 在noticeme的包目录中运行:
python3 inotify_build.py
- 这将创建一个“build”目录,其中包含ffibuilder.compile的结果
- 你现在应该可以使用noticeme了
- 不再需要inotify-build.py
备选方案
2019.7版
- 设置信息量更大的窗口标题
2019.8版
- 尽可能添加“.noticeme”配置文件