From b33463a03e1b6882a62dc53215111751c97770f0 Mon Sep 17 00:00:00 2001 From: Anthony Romaniello Date: Wed, 25 Oct 2023 12:33:04 -0400 Subject: [PATCH 1/6] Modify log levels --- scos_actions/actions/calibrate_y_factor.py | 2 +- scos_actions/calibration/__init__.py | 12 +++++------- scos_actions/capabilities/__init__.py | 7 +++---- scos_actions/discover/yaml.py | 10 ++++------ scos_actions/hardware/__init__.py | 8 ++++---- scos_actions/hardware/mocks/mock_sigan.py | 2 +- scos_actions/hardware/sigan_iface.py | 8 ++++---- scos_actions/settings.py | 2 +- scos_actions/status/status_monitor.py | 2 +- 9 files changed, 24 insertions(+), 29 deletions(-) diff --git a/scos_actions/actions/calibrate_y_factor.py b/scos_actions/actions/calibrate_y_factor.py index 94760341..11ced67c 100644 --- a/scos_actions/actions/calibrate_y_factor.py +++ b/scos_actions/actions/calibrate_y_factor.py @@ -152,7 +152,7 @@ def __init__(self, parameters, sigan, gps=None): try: self.iir_apply = get_parameter(IIR_APPLY, parameters) except ParameterException: - logger.info( + logger.debug( "Config parameter 'iir_apply' not provided. " + "No IIR filtering will be used during calibration." ) diff --git a/scos_actions/calibration/__init__.py b/scos_actions/calibration/__init__.py index 28f4359d..46fe9dbd 100644 --- a/scos_actions/calibration/__init__.py +++ b/scos_actions/calibration/__init__.py @@ -17,10 +17,9 @@ def get_sigan_calibration(sigan_cal_file: Path) -> Calibration: """ try: sigan_cal = load_from_json(sigan_cal_file) - except Exception as err: + except Exception: sigan_cal = None - logger.error("Unable to load sigan calibration data, reverting to none") - logger.exception(err) + logger.exception("Unable to load sigan calibration data, reverting to none") return sigan_cal @@ -34,10 +33,9 @@ def get_sensor_calibration(sensor_cal_file: Path) -> Calibration: """ try: sensor_cal = load_from_json(sensor_cal_file) - except Exception as err: + except Exception: sensor_cal = None - logger.error("Unable to load sensor calibration data, reverting to none") - logger.exception(err) + logger.exception("Unable to load sensor calibration data, reverting to none") return sensor_cal @@ -46,4 +44,4 @@ def get_sensor_calibration(sensor_cal_file: Path) -> Calibration: logger.info(f"Loading sigan cal file: {SIGAN_CALIBRATION_FILE}") sigan_calibration = get_sigan_calibration(SIGAN_CALIBRATION_FILE) if sensor_calibration: - logger.info(f"Last sensor cal: {sensor_calibration.last_calibration_datetime}") + logger.debug(f"Last sensor cal: {sensor_calibration.last_calibration_datetime}") diff --git a/scos_actions/capabilities/__init__.py b/scos_actions/capabilities/__init__.py index 7655434b..d17bd457 100644 --- a/scos_actions/capabilities/__init__.py +++ b/scos_actions/capabilities/__init__.py @@ -11,7 +11,7 @@ SENSOR_DEFINITION_HASH = None SENSOR_LOCATION = None -logger.info(f"Loading {SENSOR_DEFINITION_FILE}") +logger.debug(f"Loading {SENSOR_DEFINITION_FILE}") try: capabilities["sensor"] = utils.load_from_json(SENSOR_DEFINITION_FILE) except Exception as e: @@ -32,7 +32,7 @@ sensor_loc["z"] if "z" in sensor_loc else None, ) except: - logger.warning("Failed to get sensor location from sensor definition.") + logger.exception("Failed to get sensor location from sensor definition.") # Generate sensor definition file hash (SHA 512) try: @@ -41,7 +41,6 @@ SENSOR_DEFINITION_HASH = hashlib.sha512(sensor_def.encode("UTF-8")).hexdigest() capabilities["sensor"]["sensor_sha512"] = SENSOR_DEFINITION_HASH except: - logger.error(f"Unable to generate sensor definition hash") capabilities["sensor"]["sensor_sha512"] = "ERROR GENERATING HASH" # SENSOR_DEFINITION_HASH is None, do not raise Exception - logger.debug(e) + logger.exception(f"Unable to generate sensor definition hash") diff --git a/scos_actions/discover/yaml.py b/scos_actions/discover/yaml.py index ace3102f..bf76d9bd 100644 --- a/scos_actions/discover/yaml.py +++ b/scos_actions/discover/yaml.py @@ -17,22 +17,20 @@ def load_from_yaml(action_classes, sigan, gps, yaml_dir: Path = ACTION_DEFINITIO definition = yaml.load(yaml_file) for class_name, parameters in definition.items(): try: - logger.debug("Attempting to configure: " + class_name) + logger.debug(f"Attempting to configure: {class_name}") action = action_classes[class_name]( parameters=parameters, sigan=sigan, gps=gps ) parsed_actions[action.name] = action except KeyError as exc: err = "Nonexistent action class name {!r} referenced in {!r}" - logger.error(err.format(class_name, yaml_file.name)) - logger.exception(exc) + logger.exception(err.format(class_name, yaml_file.name)) raise exc except TypeError as exc: err = "Invalid parameter list {!r} referenced in {!r}" - logger.error(err.format(parameters, yaml_file.name)) - logger.exception(exc) + logger.exception(err.format(parameters, yaml_file.name)) raise exc except Exception as exc: - logger.error("Unable to load yaml:", exc, class_name, parameters) + logger.exception("Unable to load yaml:", class_name, parameters) raise exc return parsed_actions diff --git a/scos_actions/hardware/__init__.py b/scos_actions/hardware/__init__.py index 3f5b2ca8..c2a84675 100644 --- a/scos_actions/hardware/__init__.py +++ b/scos_actions/hardware/__init__.py @@ -24,14 +24,14 @@ def load_switches(switch_dir: Path) -> dict: if switch_dir is not None and switch_dir.is_dir(): for f in switch_dir.iterdir(): file_path = f.resolve() - logger.info(f"loading switch config {file_path}") + logger.debug(f"loading switch config {file_path}") conf = utils.load_from_json(file_path) try: switch = ControlByWebWebRelay(conf) - logger.info(f"Adding {switch.id}") + logger.debug(f"Adding {switch.id}") switch_dict[switch.id] = switch - logger.info(f"Registering switch status for {switch.name}") + logger.debug(f"Registering switch status for {switch.name}") register_component_with_status.send(__name__, component=switch) except ConfigurationException: logger.error(f"Unable to configure switch defined in: {file_path}") @@ -49,7 +49,7 @@ def load_preselector_from_file(preselector_config_file: Path): preselector_config, PRESELECTOR_MODULE, PRESELECTOR_CLASS ) except ConfigurationException: - logger.error( + logger.exception( f"Unable to create preselector defined in: {preselector_config_file}" ) return None diff --git a/scos_actions/hardware/mocks/mock_sigan.py b/scos_actions/hardware/mocks/mock_sigan.py index b1e82bca..46b8f2ec 100644 --- a/scos_actions/hardware/mocks/mock_sigan.py +++ b/scos_actions/hardware/mocks/mock_sigan.py @@ -140,7 +140,7 @@ def acquire_time_domain_samples( data_len = len(data) if not len(data) == num_samples: if retries > 0: - msg = "USRP error: requested {} samples, but got {}." + msg = "Signal analyzer error: requested {} samples, but got {}." logger.warning(msg.format(num_samples + num_samples_skip, data_len)) logger.warning(f"Retrying {retries} more times.") retries = retries - 1 diff --git a/scos_actions/hardware/sigan_iface.py b/scos_actions/hardware/sigan_iface.py index 99e25ab9..a12c1d67 100644 --- a/scos_actions/hardware/sigan_iface.py +++ b/scos_actions/hardware/sigan_iface.py @@ -126,7 +126,7 @@ def power_cycle_and_connect(self, sleep_time: float = 2.0) -> None: try: power_cycle_sigan() except HardwareConfigurationException as hce: - logger.warn(f"Unable to power cycle sigan: {hce}") + logger.warning(f"Unable to power cycle sigan: {hce}") return try: # Wait for power cycle to complete @@ -134,9 +134,9 @@ def power_cycle_and_connect(self, sleep_time: float = 2.0) -> None: time.sleep(sleep_time) logger.info("Power cycled signal analyzer. Reconnecting...") self.connect() - except Exception as e: - logger.error( - f"Unable to reconnect to signal analyzer after power cycling: {e}" + except Exception: + logger.exception( + "Unable to reconnect to signal analyzer after power cycling" ) return diff --git a/scos_actions/settings.py b/scos_actions/settings.py index 8ee0015c..e8236f75 100644 --- a/scos_actions/settings.py +++ b/scos_actions/settings.py @@ -7,7 +7,7 @@ logger = logging.getLogger(__name__) env = Env() -logger.info("Initializing scos-actions settings") +logger.debug("Initializing scos-actions settings") CONFIG_DIR = Path(__file__).parent.resolve() / "configs" ACTION_DEFINITIONS_DIR = CONFIG_DIR / "actions" diff --git a/scos_actions/status/status_monitor.py b/scos_actions/status/status_monitor.py index 938e1181..dd76d00b 100644 --- a/scos_actions/status/status_monitor.py +++ b/scos_actions/status/status_monitor.py @@ -5,7 +5,7 @@ class StatusMonitor: def __init__(self): - logger.info("Initializing StatusMonitor") + logger.debug("Initializing StatusMonitor") self.status_components = [] def add_component(self, component): From 06acc595677e51bba1a80ecf2b3237533232cef2 Mon Sep 17 00:00:00 2001 From: Anthony Romaniello Date: Wed, 25 Oct 2023 13:15:45 -0400 Subject: [PATCH 2/6] Bump version to 6.4.2 --- scos_actions/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scos_actions/__init__.py b/scos_actions/__init__.py index 6b5a92b6..9c4b2035 100644 --- a/scos_actions/__init__.py +++ b/scos_actions/__init__.py @@ -1 +1 @@ -__version__ = "6.4.1" +__version__ = "6.4.2" From fa2075f14feacbf78f5b73905a9341298f3be64d Mon Sep 17 00:00:00 2001 From: Anthony Romaniello Date: Wed, 25 Oct 2023 11:17:45 -0600 Subject: [PATCH 3/6] Update pre-commit hook black --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6d0c9f36..27a4ee27 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: types: [file, python] args: ["--profile", "black", "--filter-files", "--gitignore"] - repo: https://github.com/psf/black - rev: 23.10.0 + rev: 23.10.1 hooks: - id: black types: [file, python] From 3c1b9f38c4ce4f46dc35b8554c8fc24c46aa86c6 Mon Sep 17 00:00:00 2001 From: Anthony Romaniello Date: Wed, 25 Oct 2023 11:18:08 -0600 Subject: [PATCH 4/6] Run pre-commit hooks --- scos_actions/metadata/structs/ntia_diagnostics.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scos_actions/metadata/structs/ntia_diagnostics.py b/scos_actions/metadata/structs/ntia_diagnostics.py index 7f39f47c..842d74c3 100644 --- a/scos_actions/metadata/structs/ntia_diagnostics.py +++ b/scos_actions/metadata/structs/ntia_diagnostics.py @@ -122,10 +122,11 @@ class Computer(msgspec.Struct, **SIGMF_OBJECT_KWARGS): class ScosPlugin(msgspec.Struct, **SIGMF_OBJECT_KWARGS): """ Interface for generating `ntia-diagnostics` `ScosPlugin` objects. - - :param name: The Python package name as it is imported, e.g., `"scos_tekrsa"` + + :param name: The Python package name as it is imported, e.g., `"scos_tekrsa"` :param version: Version of the SCOS plugin. """ + name: Optional[str] = None version: Optional[str] = None From 9e4a9237482c856312148944c1e37f88e248b9cc Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Thu, 26 Oct 2023 05:37:13 -0600 Subject: [PATCH 5/6] Changed additional logging to debug instead of info. --- scos_actions/calibration/__init__.py | 4 ++-- scos_actions/hardware/__init__.py | 6 +++--- scos_actions/status/status_registration_handler.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scos_actions/calibration/__init__.py b/scos_actions/calibration/__init__.py index 46fe9dbd..14326964 100644 --- a/scos_actions/calibration/__init__.py +++ b/scos_actions/calibration/__init__.py @@ -39,9 +39,9 @@ def get_sensor_calibration(sensor_cal_file: Path) -> Calibration: return sensor_cal -logger.info(f"Loading sensor cal file: {SENSOR_CALIBRATION_FILE}") +logger.debug(f"Loading sensor cal file: {SENSOR_CALIBRATION_FILE}") sensor_calibration = get_sensor_calibration(SENSOR_CALIBRATION_FILE) -logger.info(f"Loading sigan cal file: {SIGAN_CALIBRATION_FILE}") +logger.debug(f"Loading sigan cal file: {SIGAN_CALIBRATION_FILE}") sigan_calibration = get_sigan_calibration(SIGAN_CALIBRATION_FILE) if sensor_calibration: logger.debug(f"Last sensor cal: {sensor_calibration.last_calibration_datetime}") diff --git a/scos_actions/hardware/__init__.py b/scos_actions/hardware/__init__.py index c2a84675..ab11e517 100644 --- a/scos_actions/hardware/__init__.py +++ b/scos_actions/hardware/__init__.py @@ -61,7 +61,7 @@ def load_preselector(preselector_config, module, preselector_class_name): preselector_constructor = getattr(preselector_module, preselector_class_name) ps = preselector_constructor(capabilities["sensor"], preselector_config) if ps and ps.name: - logger.info(f"Registering {ps.name} as status provider") + logger.debug(f"Registering {ps.name} as status provider") register_component_with_status.send(__name__, component=ps) else: ps = None @@ -69,7 +69,7 @@ def load_preselector(preselector_config, module, preselector_class_name): register_component_with_status.connect(status_registration_handler) -logger.info("Connected status registration handler") +logger.debug"Connected status registration handler") preselector = load_preselector_from_file(PRESELECTOR_CONFIG_FILE) switches = load_switches(SWITCH_CONFIGS_DIR) -logger.info(f"Loaded {(len(switches))} switches.") +logger.debug(f"Loaded {(len(switches))} switches.") diff --git a/scos_actions/status/status_registration_handler.py b/scos_actions/status/status_registration_handler.py index 48cc8b46..aed88be3 100644 --- a/scos_actions/status/status_registration_handler.py +++ b/scos_actions/status/status_registration_handler.py @@ -7,7 +7,7 @@ def status_registration_handler(sender, **kwargs): try: - logger.info(f"Registering {sender} as status provider") + logger.debug(f"Registering {sender} as status provider") status_registrar.add_component(kwargs["component"]) except: logger.exception("Error registering status component") From 992c3cefd03c4f324b7fc67cdfd6ade2fc6cb4b0 Mon Sep 17 00:00:00 2001 From: Anthony Romaniello Date: Thu, 26 Oct 2023 09:07:32 -0600 Subject: [PATCH 6/6] fix missing paranthesis --- scos_actions/hardware/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scos_actions/hardware/__init__.py b/scos_actions/hardware/__init__.py index ab11e517..34af394d 100644 --- a/scos_actions/hardware/__init__.py +++ b/scos_actions/hardware/__init__.py @@ -69,7 +69,7 @@ def load_preselector(preselector_config, module, preselector_class_name): register_component_with_status.connect(status_registration_handler) -logger.debug"Connected status registration handler") +logger.debug("Connected status registration handler") preselector = load_preselector_from_file(PRESELECTOR_CONFIG_FILE) switches = load_switches(SWITCH_CONFIGS_DIR) logger.debug(f"Loaded {(len(switches))} switches.")