Update the scheduler to use the latest config system

This commit is contained in:
Herbert Wolverson
2024-01-27 09:42:11 -06:00
parent ed5cbbc29c
commit 9c2747de37
2 changed files with 13 additions and 13 deletions

View File

@@ -74,6 +74,7 @@ fn liblqos_python(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(automatic_import_powercode))?;
m.add_wrapped(wrap_pyfunction!(powercode_api_key))?;
m.add_wrapped(wrap_pyfunction!(powercode_api_url))?;
m.add_wrapped(wrap_pyfunction!(automatic_import_sonar))?;
Ok(())
}
@@ -553,4 +554,10 @@ fn powercode_api_key() -> PyResult<String> {
fn powercode_api_url() -> PyResult<String> {
let config = lqos_config::load_config().unwrap();
Ok(config.powercode_integration.powercode_api_url)
}
#[pyfunction]
fn automatic_import_sonar() -> PyResult<bool> {
let config = lqos_config::load_config().unwrap();
Ok(config.sonar_integration.enable_sonar)
}

View File

@@ -2,22 +2,15 @@ import time
import datetime
from LibreQoS import refreshShapers, refreshShapersUpdateOnly
#from graphInfluxDB import refreshBandwidthGraphs, refreshLatencyGraphs
from liblqos_python import automatic_import_uisp, automatic_import_splynx, queue_refresh_interval_mins
from liblqos_python import automatic_import_uisp, automatic_import_splynx, queue_refresh_interval_mins, \
automatic_import_powercode, automatic_import_sonar
if automatic_import_uisp():
from integrationUISP import importFromUISP
if automatic_import_splynx():
from integrationSplynx import importFromSplynx
try:
from ispConfig import automaticImportPowercode
except:
automaticImportPowercode = False
if automaticImportPowercode:
if automatic_import_powercode():
from integrationPowercode import importFromPowercode
try:
from ispConfig import automaticImportSonar
except:
automaticImportSonar = False
if automaticImportSonar:
if automatic_import_sonar():
from integrationSonar import importFromSonar
from apscheduler.schedulers.background import BlockingScheduler
from apscheduler.executors.pool import ThreadPoolExecutor
@@ -35,12 +28,12 @@ def importFromCRM():
importFromSplynx()
except:
print("Failed to import from Splynx")
elif automaticImportPowercode:
elif automatic_import_powercode():
try:
importFromPowercode()
except:
print("Failed to import from Powercode")
elif automaticImportSonar:
elif automatic_import_sonar():
try:
importFromSonar()
except: