-
Notifications
You must be signed in to change notification settings - Fork 4
/
handler.py
31 lines (24 loc) · 884 Bytes
/
handler.py
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
import subprocess
import sys
from FileMonitor import created, start, deleted
@created(r'py', once=True)
def pys(src_path):
pass
# print(pys.__re_path__)
print(pys.__method__)
# print("test:", src_path)
@start(r'.*py', once=True, )
def sl(src_path):
print("sl:", src_path)
command = ['python3', src_path]
print('Start process %s...' % ' '.join(command))
process = subprocess.Popen(command, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr)
@deleted(src_path, once=True, escape=True, process=process)
def fk(src_path):
print('Kill process [%s]...' % fk.__data__['process'].pid)
fk.__data__['process'].kill()
fk.__data__['process'].wait()
print('Process ended with code %s.' % fk.__data__['process'].returncode)
process = None
print("fk:", src_path)
sl.__app__.register_callback(fk)