跳转到主要内容

从文件系统事件触发自定义命令。

项目描述

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 (5.6 kB 查看哈希值)

上传时间

由...

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误日志StatusPageStatusPage状态页面