Giter Club home page Giter Club logo

inotipy's Introduction

inotipy's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

diefans

inotipy's Issues

pathname not set when watching files

During development, I need to watch certain files (not directories) that change and reload them. inotipy does see the changes to these files but does not provide the name of the file that changed, which forces me to either watch the directories in which these files are and filter on the filename, or have one watcher per file. It would be more intuitive to have only one watcher for all these files and get the name of the file that indeed changed.

A basic example:

  • create two files foo and bar in /tmp:
$ echo 1 > /tmp/foo
$ echo 2 > /tmp/bar 
  • run a watcher for these two files:
import sys
import asyncio
import inotify

async def mainline() :
    watcher = inotify.Watcher.create()
    for path in  ('/tmp/foo','/tmp/bar'):
        watcher.watch(path, inotify.IN.ALL_EVENTS)
    while True :
        event = await watcher.get()
        sys.stdout.write("Got event: %s\n" % repr(event))

loop = asyncio.get_event_loop()
loop.run_until_complete(mainline())
  • change the content of the files:
$ echo 3 > /tmp/foo 
$ echo 4 > /tmp/bar 
  • see that we cannot tell which file actually changed:
Got event: Event(1, 0x00000002[<EVENT_BIT.MODIFY: 1>], 0, '')
Got event: Event(1, 0x00000020[<EVENT_BIT.OPEN: 5>], 0, '')
Got event: Event(1, 0x00000002[<EVENT_BIT.MODIFY: 1>], 0, '')
Got event: Event(1, 0x00000008[<EVENT_BIT.CLOSE_WRITE: 3>], 0, '')
Got event: Event(2, 0x00000002[<EVENT_BIT.MODIFY: 1>], 0, '')
Got event: Event(2, 0x00000020[<EVENT_BIT.OPEN: 5>], 0, '')
Got event: Event(2, 0x00000002[<EVENT_BIT.MODIFY: 1>], 0, '')
Got event: Event(2, 0x00000008[<EVENT_BIT.CLOSE_WRITE: 3>], 0, '')

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.