Giter VIP home page Giter VIP logo

fsmonitor's Introduction

fsmonitor - Filesystem Monitoring for Python

Supported Platforms

  • Linux 2.6 (inotify)
  • Windows (ReadDirectoryChangesW with I/O completion ports)
  • Any other platform (polling)

Installation

$ python setup.py install

Introduction

The fsmonitor module provides live filesystem monitoring. It can be used to monitor for events such as file creation, deletion, modification and so on:

from fsmonitor import FSMonitor

The FSMonitor class manages filesystem watches and is used to receive events. Call the add_dir_watch() method to add a directory watch to the monitor:

m = FSMonitor()
watch = m.add_dir_watch("/dir/to/watch")

Once a watch has been added, you can call read_events() to read a list of filesystem events. This is a blocking call and in some cases it might return an empty list, so it needs to be re-called repeatedly to get more events:

while True:
    for evt in m.read_events():
        print evt.action_name, evt.name

The FSMonitorThread class can be used to receive events asynchronously with a callback. The callback will be called from another thread so it is responsible for thread-safety. If a callback is not specified, the thread will collect events in a list which can be read by calling read_events().

More Details

See the example code in the examples directory.

Contact Details

Please send any comments or questions to: [email protected]

Please report bugs on the github issue tracker.

-- Luke McCarthy

fsmonitor's People

Contributors

ljmccarthy avatar apg avatar jason-s avatar kundor avatar thomashickman avatar

Watchers

James Cloos 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.