-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
35 lines (26 loc) · 864 Bytes
/
run.py
File metadata and controls
35 lines (26 loc) · 864 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
34
35
import os
import subprocess
import time
from time import sleep
from watchdog.events import LoggingEventHandler
from watchdog.observers import Observer
shouldR = False
lastEvent = time.time()
class Event(LoggingEventHandler):
def dispatch(self, event):
global lastEvent
global shouldR
filename, file_extension = os.path.splitext(event.src_path)
if file_extension == ".dart":
if lastEvent < time.time() - 0.2:
lastEvent = time.time()
process.stdin.write(b'r\n')
process.stdin.flush()
print("Modified!")
event_handler = Event()
observer = Observer()
observer.schedule(event_handler, '.', recursive=True)
observer.start()
process = subprocess.Popen(['flutter', 'run', '-d', 'windows'], shell=True, stdin=subprocess.PIPE)
while True:
sleep(10)