Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitor.py
More file actions
Latest commit
46 lines (34 loc) · 1.13 KB
/
Copy pathmonitor.py
File metadata and controls
46 lines (34 loc) · 1.13 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
importos
importtime
fromabstracts.monitorimportIFileObserver, IFolderMonitor
classFolderMonitor(IFolderMonitor):
def__init__(self, src_path=""):
self.__observers:list[IFileObserver] = []
self.__src_path=src_pathifsrc_pathelseos.getcwd()
defattach(self, observer=None):
try:
ifobserver:
self.__observers.append(observer)
exceptExceptionase:
raisee
defdetach(self, observer=None):
try:
ifobserver:
self.__observers.remove(observer)
exceptExceptionase:
raisee
defnotify(self, files=[]):
try:
forobsinself.__observers:
obs.update(files)
exceptExceptionase:
raisee
defstart(self, period=60):
try:
whileTrue:
files= [fforfinos.listdir(self.__src_path) ifos.path.isfile(os.path.join(self.__src_path, f))]
iffiles:
self.notify(files)
time.sleep(period)
exceptExceptionase:
raisee