I'm creating a desktop application that notifies the user whenever a file has been modified, I've only just started using all of these modules and going through the documentation. Here is my code so far:
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.
Could someone help me with these 2 issues?
Edit: I've also just been told that the real spreadsheet that will be observed is on a sharepoint google spreadsheet.
Can I use the watchdog observer for an online spreadsheet, or will I need to use a different module?
import time from watchdog.observers import Observer from watchdog.events import LoggingEventHandler from winotify import Notification, audio import logging import getpass def on_modified(event): toast.set_audio(audio.Default, loop=False) toast.show() if __name__ == '__main__': user = getpass.getuser() logging.basicConfig(filename='E:/DataLogging/log.log', filemode='a', level=logging.INFO, format='%(asctime)s - %(message)s' + f' - user: {user}', datefmt='%Y-%m-%d %H:%M:%S') path = 'E:/Datalogging/' toast = Notification(app_id="Spreadsheet Notification", title="Spreadsheet Updated", msg=f'{user} has modified the spreadsheet', icon=r'E:/download.jpg') event_handler = LoggingEventHandler() event_handler.on_modified = on_modified observer = Observer() observer.schedule(event_handler, path, recursive=True) observer.start() try: while True: time.sleep(1) except KeyboardInterrupt: observer.stop() observer.join()But, I've noticed that the user is notified any time someone opens up, modifies, and closes the file, but I only want the user to be notified whenever it is only modified, and not opened or closed.
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.
Could someone help me with these 2 issues?
Edit: I've also just been told that the real spreadsheet that will be observed is on a sharepoint google spreadsheet.
Can I use the watchdog observer for an online spreadsheet, or will I need to use a different module?