You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
585 B

6 years ago
  1. import os
  2. from PIL import Image
  3. from PIL.ImageOps import grayscale
  4. from watchdog.events import RegexMatchingEventHandler
  5. class FilesEventHandler(RegexMatchingEventHandler):
  6. FILES_REGEX = [r".*[^_thumbnail]\.jpg$"]
  7. socketio = None
  8. def __init__(self,socketio):
  9. self.socketio = socketio
  10. super().__init__(self.FILES_REGEX)
  11. def on_any_event(self, event):
  12. print("File change occured")
  13. filename, ext = os.path.splitext(event.src_path)
  14. print("{}_socket".format(filename.split(".")[0]))
  15. self.socketio.emit("new", "new", namespace="{}_socket".format(filename.split(".")[0]))