-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilesystem_handler.py
More file actions
33 lines (27 loc) · 1020 Bytes
/
filesystem_handler.py
File metadata and controls
33 lines (27 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import asyncio
from watchdog.events import FileSystemEventHandler
class FileSystemHandler(FileSystemEventHandler):
def __init__(self, filesystem,opcua_server):
super().__init__()
self.filesystem = filesystem
self.server = opcua_server
def on_created(self, event):
asyncio.run_coroutine_threadsafe(
self.filesystem.update_filesystem(event.src_path, 'created'),
self.server.loop
)
def on_deleted(self, event):
asyncio.run_coroutine_threadsafe(
self.filesystem.update_filesystem(event.src_path, 'deleted'),
self.server.loop
)
def on_modified(self, event):
asyncio.run_coroutine_threadsafe(
self.filesystem.update_filesystem(event.src_path, 'modified'),
self.server.loop
)
def on_moved(self, event):
asyncio.run_coroutine_threadsafe(
self.filesystem.update_filesystem(event.dest_path, 'moved'),
self.server.loop
)