From 0b78c84ac06c38c9f897b000bbb266bd07bcf808 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Tue, 5 Apr 2022 00:22:21 +0400 Subject: [PATCH] selfcheck.py: consider locale settings while converting `top` output top uses locale to format numbers, so using simple float() doesn't work in case of locales using comma as decimal separator --- clover/src/selfcheck.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clover/src/selfcheck.py b/clover/src/selfcheck.py index db3605c1..840fee49 100755 --- a/clover/src/selfcheck.py +++ b/clover/src/selfcheck.py @@ -30,6 +30,7 @@ from visualization_msgs.msg import MarkerArray as VisualizationMarkerArray import tf.transformations as t from aruco_pose.msg import MarkerArray from mavros import mavlink +import locale # TODO: check attitude is present @@ -45,6 +46,8 @@ rospy.init_node('selfcheck') os.environ['ROSCONSOLE_FORMAT']='[${severity}]: ${message}' +# use user's locale to convert numbers, etc +locale.setlocale(locale.LC_ALL, '') tf_buffer = tf2_ros.Buffer() tf_listener = tf2_ros.TransformListener(tf_buffer) @@ -638,7 +641,7 @@ def check_cpu_usage(): continue pid, cpu, cmd = process.split('\t') - if cmd.strip() not in WHITELIST and float(cpu) > 30: + if cmd.strip() not in WHITELIST and locale.atof(cpu) > 30: failure('high CPU usage (%s%%) detected: %s (PID %s)', cpu.strip(), cmd.strip(), pid.strip())