Skip to main content

Runs Python functions once a certain file is created or modified.

Project description

FileWatchdog

Documentation Status PyPI Downloads Downloads License

Runs Python functions once a certain file is created or modified.

Installation

pip install filewatchdog

Usage

import filewatchdog as watcher
import time

def job():
    print("I'm working...")


# detecting changes to one single file

watcher.once().file('C:/Temp/1.txt').modified.do(job)
watcher.once().file('C:/Temp/1.txt').exist.do(job)


# detecting file changes in a directory recursively

watcher.once().folder('C:/Temp').modified.do(job)
watcher.once().folder('C:/Temp').exist.do(job)


# watching multiple files

files = ['C:/Temp/1.txt', 'C:/Temp/2.txt', 'C:/Temp/3.txt']

watcher.once().one_of(files).modified.do(job)
watcher.once().all_of(files).exist.do(job)


while True:
    watcher.run_pending()
    time.sleep(1)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

filewatchdog-0.1.1.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

filewatchdog-0.1.1-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page