-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
scheduler.py
79 lines (70 loc) · 2.02 KB
/
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
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
74
75
76
77
78
79
import time
import datetime
from LibreQoS import refreshShapers, refreshShapersUpdateOnly
from graphInfluxDB import refreshBandwidthGraphs, refreshLatencyGraphs
from ispConfig import influxDBEnabled, automaticImportUISP, automaticImportSplynx
try:
from ispConfig import queueRefreshIntervalMins
except:
queueRefreshIntervalMins = 30
if automaticImportUISP:
from integrationUISP import importFromUISP
if automaticImportSplynx:
from integrationSplynx import importFromSplynx
try:
from ispConfig import automaticImportPowercode
except:
automaticImportPowercode = False
if automaticImportPowercode:
from integrationPowercode import importFromPowercode
try:
from ispConfig import automaticImportSonar
except:
automaticImportSonar = False
if automaticImportSonar:
from integrationSonar import importFromSonar
from apscheduler.schedulers.background import BlockingScheduler
from apscheduler.executors.pool import ThreadPoolExecutor
ads = BlockingScheduler(executors={'default': ThreadPoolExecutor(1)})
def importFromCRM():
if automaticImportUISP:
try:
importFromUISP()
except:
print("Failed to import from UISP")
elif automaticImportSplynx:
try:
importFromSplynx()
except:
print("Failed to import from Splynx")
elif automaticImportPowercode:
try:
importFromPowercode()
except:
print("Failed to import from Powercode")
elif automaticImportSonar:
try:
importFromSonar()
except:
print("Failed to import from Sonar")
def graphHandler():
try:
refreshBandwidthGraphs()
except:
print("Failed to update bandwidth graphs")
try:
refreshLatencyGraphs()
except:
print("Failed to update latency graphs")
def importAndShapeFullReload():
importFromCRM()
refreshShapers()
def importAndShapePartialReload():
importFromCRM()
refreshShapersUpdateOnly()
if __name__ == '__main__':
importAndShapeFullReload()
ads.add_job(importAndShapePartialReload, 'interval', minutes=queueRefreshIntervalMins, max_instances=1)
if influxDBEnabled:
ads.add_job(graphHandler, 'interval', seconds=10, max_instances=1)
ads.start()