/
Scheduler.py
34 lines (30 loc) · 962 Bytes
/
Scheduler.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
32
33
34
import schedule
from winsys import ipc
import Scanner
def Scan(path):
client_mon = ipc.mailslot("monitoring_client")
exes = Scanner.find_exe(path)
total = len(exes)
if total == 0:
return
for exe in exes:
res = Scanner.scan(exe)
try:
client_mon.put({'progress': None, 'exe': exe, 'infected': res, 'marker': 'sched'})
except Exception:
print('Клиент выключен.')
break
def startScheduling(path, interval, flag):
global job1
if interval == 30:
job1 = schedule.every(interval).seconds.do(Scan, path, flag)
job2 = schedule.every(interval).minutes.do(Scan, path, flag)
schedule.run_pending()
while True:
if flag:
if interval == 30:
print('ddd')
schedule.cancel_job(job1)
else:
schedule.cancel_job(job2)
break