Giter Site home page Giter Site logo

aionotify's Introduction

aionotify

https://secure.travis-ci.org/rbarrois/aionotify.png?branch=master Latest Version Supported Python versions Wheel status License

aionotify is a simple, asyncio-based inotify library.

Its use is quite simple:

import asyncio
import aionotify

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

# Prepare the loop
loop = asyncio.get_eventloop()

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

loop.run_until_completed(work())
loop.stop()
loop.close()

Links

Events

An event is a simple object with a few attributes:

  • name: the path of the modified file
  • flags: the modification flag; use aionotify.Flags.parse() to retrieve a list of individual values.
  • alias: the alias of the watch triggering the event
  • cookie: for renames, this integer value links the "renamed from" and "renamed to" events.

Watches

aionotify uses a system of "watches", similar to inotify.

A watch may have an alias; by default, it uses the path name:

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

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

A watch can be removed by using its alias:

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

watcher.unwatch('/var/log')

aionotify's People

Contributors

rbarrois avatar rexchemdev avatar rickwierenga avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.