Questions tagged [python-watchdog]

Use this tag with questions related to the Python library Watchdog, a tool to monitor file system events. You should also specify the tag [python] and eventually the version used.

Watchdog is a Python API library and shell utilities to monitor file system events.

See more:

242 questions
18
votes
2 answers

How to run an function when anything changes in a dir with Python Watchdog?

I'm trying to use watchdog to run a sync script whenever anything changes in a dir (except for one specific file). I simply copied the code from the readme (pasted below), which does what it says; log which file has changed. import sys import…
kramer65
  • 50,427
  • 120
  • 308
  • 488
14
votes
10 answers

Python watchdog windows wait till copy finishes

I am using the Python watchdog module on a Windows 2012 server to monitor new files appearing on a shared drive. When watchdog notices the new file it kicks off a database restore process. However, it seems that watchdog will attempt to restore the…
tjmgis
  • 1,589
  • 4
  • 23
  • 42
13
votes
5 answers

How to refresh the boto3 credetials when python script is running indefinitely

I am trying to write a python script that uses watchdog to look for file creation and upload that to s3 using boto3. However, my boto3 credentials expire after every 12hrs, So I need to renew them. I am storing my boto3 credentials in…
shruthi chowdhary
  • 131
  • 1
  • 1
  • 4
11
votes
3 answers

"cannot import name 'EVENT_TYPE_OPENED' from 'watchdog.events' "

I'm trying to make a REST api (begginer) but when i tried to initialize the server from this code: from flask import Flask app = Flask(__name__) if __name__=='__main__': app.run(debug=True, port=4000) i get this error in the prompt: from…
10
votes
2 answers

Simplest way for PyQT Threading

I have a GUI in PyQt with a function addImage(image_path). Easy to imagine, it is called when a new image should be added into a QListWidget. For the detection of new images in a folder, I use a threading.Thread with watchdog to detect file changes…
user3696412
  • 1,321
  • 3
  • 15
  • 33
10
votes
0 answers

Watchdog getting events thrice in Python 3

I'm creating a program in Python using Watchdog that watches a set of files and takes actions based on changes. I put the exact example from their site in a file: import sys import time import logging from watchdog.observers import Observer from…
PurkkaKoodari
  • 6,703
  • 6
  • 37
  • 58
10
votes
1 answer

How do I watch a file, not a directory for changes using Python?

The question: How do I watch a file for changes using Python? suggests using watchdog, but I found it was only able to watch a directory, not a file. watchdog-test.py is watchdog's sample script: $ python watchdog-test.py ab_test_res.sh & [1]…
laike9m
  • 18,344
  • 20
  • 107
  • 140
6
votes
2 answers

How to fix ‘“ERROR: Command errored out with exit status 1:” when trying to install watchdog using pip

I am revisiting the python language and experiencing difficulty setting up my environment. I am using - Mac Mojave (10.14) - python 2.7.10 (packaged with the system) - python 3.7.4 (installed using homebrew) - homebrew 2.1.14 - pip 19.2.3 I…
chronowalker
  • 63
  • 1
  • 1
  • 3
6
votes
2 answers

flask application with watchdog observer

I am seeking for an example for flask-based web application with watchdog observer. More specifically, I want to use the watchdog observer to detect any changes in pre-defined directories and update a web application based on the changes. I can find…
Sungsoo Ha
  • 265
  • 4
  • 14
5
votes
2 answers

Python Watchdog process existing files on startup

I have a simple Watchdog and Queue process to monitor files in a directory. Code taken from https://camcairns.github.io/python/2017/09/06/python_watchdog_jobs_queue.html import time from watchdog.events import PatternMatchingEventHandler from…
scottyj
  • 51
  • 3
5
votes
1 answer

How to check for change in the directory at FTP server?

I want to get the file from FTP server to local as soon as new file is added in directory on FTP. I know changes in the directory at local machine can be seen using watchdog observer. But I want to check for the change in the directory (addition of…
Aayan Arora
  • 77
  • 2
  • 7
5
votes
1 answer

Watchdog observer not running in container

I am using watchdog to monitor a file directory for filesystem events. If this watcher script detects an event, I want to make an entry in a database (in this case Mongodb). The file system to be watched is actually a Docker volume linking its…
user3535074
  • 1,268
  • 8
  • 26
  • 48
5
votes
1 answer

Python watchdog: How to handle the watched directory being deleted?

I am happily using the watchdog package, specifically PollingObserver, to watch directories for file events. It works great - until the directory I am watching is deleted. What then happens is the code that is polling the directory calls stat() on a…
Jeffrey DeLeo
  • 1,672
  • 13
  • 19
5
votes
1 answer

Using python-watchdog to monitor a folder, but when I rename a file, I haven't been able to find a way to see the new filename

Renaming a file that is being monitored in watchdog produces a on_moved event trigger. The problem I'm having is that there is no way to tell what the file was moved/renamed to (as the on_moved event trigger also happens when a file was renamed). Is…
Luis F Hernandez
  • 891
  • 2
  • 14
  • 29
4
votes
1 answer

watchdog(python) - monitor only one file format and ignore everything else in 'PatternMatchingEventHandler'

I'm running code from this article and made some changes to monitor file creations/additions of only one format, that's .csv in a specified directory. the problem now is: My program breaks(stops monitoring, but keeps running), whenever the new…
Naveen Reddy Marthala
  • 2,622
  • 4
  • 35
  • 67
1
2 3
16 17