From 83791865fdba7bb8f4caa96751a9ac4541a0e153 Mon Sep 17 00:00:00 2001 From: Axel Garcia Date: Wed, 7 Jan 2026 11:55:25 +0100 Subject: [PATCH] ENH: Implement python probe for verbose mode --- applications/rtkargumentparser.py | 23 +++++++++++++++++++++++ pyproject.toml | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/applications/rtkargumentparser.py b/applications/rtkargumentparser.py index bcf6c8023..30b1dc86d 100644 --- a/applications/rtkargumentparser.py +++ b/applications/rtkargumentparser.py @@ -5,6 +5,27 @@ import inspect from typing import Optional + +def _enable_global_resource_probe_if_available(verbose: bool) -> None: + if not verbose: + return + + # Mirror the C++ apps: --verbose enables RTK probe reporting (when compiled in). + try: + grp = getattr(rtk, "GlobalResourceProbe", None) + if grp is None: + return + + instance = grp.GetInstance() if hasattr(grp, "GetInstance") else grp.New() + if hasattr(instance, "SetVerbose"): + instance.SetVerbose(True) + elif hasattr(instance, "VerboseOn"): + instance.VerboseOn() + except Exception: + # Keep --verbose best-effort and never fail the application. + return + + __all__ = ["RTKArgumentParser"] @@ -97,6 +118,8 @@ def parse_args(self, args=None, namespace=None): # Case 2: normal space-separated form (e.g. "1 2 3"). Just cast every token. setattr(namespace, dest, [caster(tk) for tk in val]) action.type = neutralized[dest] + + _enable_global_resource_probe_if_available(getattr(namespace, "verbose", False)) return namespace def parse_kwargs(self, func_name: Optional[str] = None, **kwargs): diff --git a/pyproject.toml b/pyproject.toml index 7db108f2f..e5a72cfbc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,7 +89,7 @@ cmake.version = ">=3.16.3" cmake.args = [] # A table of defines to pass to CMake when configuring the project. Additive. -cmake.define = {} +cmake.define = { RTK_PROBE_EACH_FILTER = "ON" } # Verbose printout when building. cmake.verbose = true