diff --git a/tracetools_launch/tracetools_launch/action.py b/tracetools_launch/tracetools_launch/action.py index 5f30f16..e549e3e 100644 --- a/tracetools_launch/tracetools_launch/action.py +++ b/tracetools_launch/tracetools_launch/action.py @@ -14,7 +14,6 @@ """Module for the Trace action.""" -import os import re import subprocess from typing import List @@ -26,6 +25,7 @@ from launch.actions import SetEnvironmentVariable from launch.event import Event from launch.event_handlers import OnShutdown from launch.launch_context import LaunchContext +from tracetools_trace import tracing_supported from tracetools_trace.tools import lttng from tracetools_trace.tools import names from tracetools_trace.tools import path @@ -94,7 +94,7 @@ class Trace(Action): :param lib_name: the name of the shared library :return: the full path if found, `None` otherwise """ - if os.name == 'nt': + if not tracing_supported(): return None (exit_code, output) = subprocess.getstatusoutput(f'whereis -b {lib_name}') if exit_code != 0: diff --git a/tracetools_trace/tracetools_trace/tools/__init__.py b/tracetools_trace/tracetools_trace/tools/__init__.py index 4b18865..e9bbd18 100644 --- a/tracetools_trace/tracetools_trace/tools/__init__.py +++ b/tracetools_trace/tracetools_trace/tools/__init__.py @@ -11,3 +11,15 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +"""Module for tracing.""" + +import sys + + +def tracing_supported() -> bool: + """ + Check if tracing is supported on this platform. + It does not mean a tracer is installed. + """ + return sys.platform == 'linux'