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!(automatic_import_powercode))?;
m.add_wrapped(wrap_pyfunction!(powercode_api_key))?; m.add_wrapped(wrap_pyfunction!(powercode_api_key))?;
m.add_wrapped(wrap_pyfunction!(powercode_api_url))?; m.add_wrapped(wrap_pyfunction!(powercode_api_url))?;
m.add_wrapped(wrap_pyfunction!(automatic_import_sonar))?;
Ok(()) Ok(())
} }
@@ -554,3 +555,9 @@ fn powercode_api_url() -> PyResult<String> {
let config = lqos_config::load_config().unwrap(); let config = lqos_config::load_config().unwrap();
Ok(config.powercode_integration.powercode_api_url) 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 import datetime
from LibreQoS import refreshShapers, refreshShapersUpdateOnly from LibreQoS import refreshShapers, refreshShapersUpdateOnly
#from graphInfluxDB import refreshBandwidthGraphs, refreshLatencyGraphs #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(): if automatic_import_uisp():
from integrationUISP import importFromUISP from integrationUISP import importFromUISP
if automatic_import_splynx(): if automatic_import_splynx():
from integrationSplynx import importFromSplynx from integrationSplynx import importFromSplynx
try: if automatic_import_powercode():
from ispConfig import automaticImportPowercode
except:
automaticImportPowercode = False
if automaticImportPowercode:
from integrationPowercode import importFromPowercode from integrationPowercode import importFromPowercode
try: if automatic_import_sonar():
from ispConfig import automaticImportSonar
except:
automaticImportSonar = False
if automaticImportSonar:
from integrationSonar import importFromSonar from integrationSonar import importFromSonar
from apscheduler.schedulers.background import BlockingScheduler from apscheduler.schedulers.background import BlockingScheduler
from apscheduler.executors.pool import ThreadPoolExecutor from apscheduler.executors.pool import ThreadPoolExecutor
@@ -35,12 +28,12 @@ def importFromCRM():
importFromSplynx() importFromSplynx()
except: except:
print("Failed to import from Splynx") print("Failed to import from Splynx")
elif automaticImportPowercode: elif automatic_import_powercode():
try: try:
importFromPowercode() importFromPowercode()
except: except:
print("Failed to import from Powercode") print("Failed to import from Powercode")
elif automaticImportSonar: elif automatic_import_sonar():
try: try:
importFromSonar() importFromSonar()
except: except: