从文件系统事件触发自定义命令。
项目描述
Patrol
从更改的文件触发方法 - 例如,当您在文本编辑器或IDE中点击保存按钮时,可以选择性地重新构建您的项目或运行测试。
Patrol与ProjectKey配合良好。
使用
安装
pip install patrol
示例代码
import patrol
def build(filenames):
touch("output/build_started")
time.sleep(2)
touch("output/build_finished")
def run_test(filenames):
touch("output/test_started")
time.sleep(30)
touch("output/test_finished")
patrol.watch([
patrol.Trigger(
build,
includes=["data/*", ],
excludes=['data/exclude/*', 'output/*', ],
),
patrol.Trigger(
run_test,
includes=["data/*", ],
excludes=['data/exclude/*', 'output/*', ],
reaper=patrol.Reaper(), # If triggered while method is in progress, this will stop it and start it again.
fire_on_initialization=True, # When the watch is initiated, this trigger will also fire.
),
],
directory=os.getcwd(), # By default it patrols the present working directory.
lockfiles=[".git/index.lock", ], # This will wait until git has finished its operations before firing any triggers
)
功能
Patrol不使用轮询来检测文件更改。它使用libuv,该库使用epoll、kqueue或IOCP创建事件驱动的钩子来处理文件系统事件。
当存在指定的锁文件时,您可以排队触发器 - 例如,您可以使用它来防止在git操作完成后触发。
Patrol附带一个自定义的Reaper类,可用于指定如何停止进程。
项目详情
关闭
patrol-0.3.1.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 47534ed32c5ff85f8b2f067fbc3aa0a6361f6c751414915ba225f9e3875b7331 |
|
MD5 | 9f0a7fcf7929f82bf8fcec8ec5c661c6 |
|
BLAKE2b-256 | a725e9f2d078a668f966c8cb3ad557b77e4bb3cf5d3d65152ffffa9df99c8082 |