Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
watchdog on_modified
#4
Quote:Also, I cannot use the path 'E:/DataLogging/test.xlsx' but I can use 'E:/DataLogging/', which is the directory, and not the specific file. I'm sure there is an easy fix for this, but I cannot find the fix yet.
watchdogs looks for changes to the file system, not to files. If you want to ignore modification events for other files in E:\Datalogging, you'll have to write that into your event callback.
def callback(event):
    """Print message if test.txt is modified."""
    if Path(event.src_path).name == "test.txt":
        print("File changed!!!")


event_handler = LoggingEventHandler()
event_handler.on_modified = callback
observer = Observer()
observer.schedule(event_handler, ".")
observer.start()
Reply


Messages In This Thread
watchdog on_modified - by CAD79 - Apr-23-2024, 01:58 PM
RE: watchdog on_modified - by deanhystad - Apr-23-2024, 03:09 PM
RE: watchdog on_modified - by CAD79 - Apr-24-2024, 08:55 AM
RE: watchdog on_modified - by deanhystad - Apr-24-2024, 06:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error when using Watchdog and Qt to keep open a Queue before and after sending first pyhill00 0 1,637 Oct-28-2021, 09:10 AM
Last Post: pyhill00
  How would I use Watchdog to get triggered when DVD is inserted? Daring_T 12 4,896 Aug-17-2021, 01:49 PM
Last Post: Daring_T

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020