跳转到主要内容

由Asyncio驱动的inotify库

项目描述

Latest Version Supported Python versions Wheel status License

aionotify 是一个基于 asyncio 的简单 inotify 库。

其使用非常简单

import asyncio
import aionotify

# Setup the watcher
watcher = aionotify.Watcher()
watcher.watch(alias='logs', path='/var/log', flags=aionotify.Flags.MODIFY)

async def work():
    await watcher.setup()
    for _i in range(10):
        # Pick the 10 first events
        event = await watcher.get_event()
        print(event)
    watcher.close()

asyncio.run(work())

事件

事件是一个具有少量属性的简单对象

  • name:修改文件的路径

  • flags:修改标志;使用 aionotify.Flags.parse() 获取单独值列表。

  • alias:触发事件的监视器别名

  • cookie:对于重命名,此整数值将“重命名自”和“重命名到”事件链接起来。

监视器

aionotify 使用类似于 inotify 的“监视器”系统。

监视器可以有一个别名;默认情况下,它使用路径名称

watcher = aionotify.Watcher()
watcher.watch('/var/log', flags=aionotify.Flags.MODIFY)

# Similar to:
watcher.watch('/var/log', flags=aionotify.Flags.MODIFY, alias='/var/log')

可以通过使用其别名来删除监视器

watcher = aionotify.Watcher()
watcher.watch('/var/log', flags=aionotify.Flags.MODIFY)

watcher.unwatch('/var/log')

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪一个,请了解更多关于安装包的信息。

源代码分发

aionotify-0.3.1.tar.gz (11.3 kB 查看哈希值)

上传时间 源代码

构建分发

aionotify-0.3.1-py2.py3-none-any.whl (7.4 kB 查看哈希值)

上传时间 Python 2 Python 3

支持者

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