From 9c2747de3703c9a23948d809411315bfc0533bfd Mon Sep 17 00:00:00 2001 From: Herbert Wolverson Date: Sat, 27 Jan 2024 09:42:11 -0600 Subject: [PATCH] Update the scheduler to use the latest config system --- src/rust/lqos_python/src/lib.rs | 7 +++++++ src/scheduler.py | 19 ++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/rust/lqos_python/src/lib.rs b/src/rust/lqos_python/src/lib.rs index 61f27621..35cf75e7 100644 --- a/src/rust/lqos_python/src/lib.rs +++ b/src/rust/lqos_python/src/lib.rs @@ -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 { fn powercode_api_url() -> PyResult { let config = lqos_config::load_config().unwrap(); Ok(config.powercode_integration.powercode_api_url) +} + +#[pyfunction] +fn automatic_import_sonar() -> PyResult { + let config = lqos_config::load_config().unwrap(); + Ok(config.sonar_integration.enable_sonar) } \ No newline at end of file diff --git a/src/scheduler.py b/src/scheduler.py index 7794a757..25b16b4a 100644 --- a/src/scheduler.py +++ b/src/scheduler.py @@ -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: