-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_runner.py
More file actions
76 lines (60 loc) · 1.92 KB
/
test_runner.py
File metadata and controls
76 lines (60 loc) · 1.92 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# from src.core.Inotify import *
# from src.WatcherPath import WatcherPath
# from src.Watcher import Watcher
# import subprocess
# # fd = inotify_init()
# # wd = inotify_add_watch(fd,b".",InotifyEvent.IN_ALL_EVENTS)
# # import os
# # while True:
# # data = os.read(fd,EVENT_BUFFER_SIZE)
# # for event in InotifyEvent.parse_event(data):
# # print(event)
# path1 = WatcherPath("/home/arnab/Desktop/system-implementations/py-mon/example/")
# j = 0
# # for i in p.get_all_files():
# # if j == 8:
# # break
# # print(i)
# # j+=1
from src.pymon.core.Inotify import InotifyEvent
RELOAD_EVENTS = (
InotifyEvent.IN_MODIFY
| InotifyEvent.IN_CLOSE_WRITE
| InotifyEvent.IN_MOVED_TO
| InotifyEvent.IN_CREATE
)
# watcher = Watcher().add(path1).on(RELOAD_EVENTS)
# # with watcher as data:
# # for event in data:
# # print(event)
# # print(path1.get_dirs())
# from src.core.Command import Command
# command = Command("python3 example/test.py")
# for data in watcher.read_events():
# if data:
# command.run()
from src.pymon.core.WatcherPath import WatcherPath
core_path = WatcherPath(
"/home/arnab/Desktop/system-implementations/py-mon/src/core", ignore=[]
)
test_path = WatcherPath(
"/home/arnab/Desktop/system-implementations/py-mon/example", ignore=[]
)
from src.pymon.core.Command import Command
from src.pymon.core.Watcher import Watcher
watcher = Watcher().add_path(core_path, test_path).add_event(RELOAD_EVENTS)
command = Command("python3 example/hellow.py")
print(watcher._wd_path_map)
from src.pymon.core.Buffer import Buffer
buffer = Buffer()
watcher.publish_to(buffer)
try:
with watcher as watch_events:
for file_path, event in watch_events:
if file_path:
# may produce duplicate events
# Debouncing at the consuemr level
command.run()
except Exception as e:
print(e)
print("exception")