From d539753e72216365a6469defa7791aed15d4cf60 Mon Sep 17 00:00:00 2001 From: Alexey Rogachevskiy Date: Thu, 15 Oct 2020 23:39:54 +0300 Subject: [PATCH] clover/selfcheck: Be more python3-compatible This is basically commit a01d199890f06716a7149f1117326272a4025eef from buster-python3, not sure if it aged well. --- clover/src/selfcheck.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/clover/src/selfcheck.py b/clover/src/selfcheck.py index 1a3cddf1..25e413e1 100755 --- a/clover/src/selfcheck.py +++ b/clover/src/selfcheck.py @@ -138,7 +138,7 @@ def mavlink_exec(cmd, timeout=3.0): timeout=3, baudrate=0, count=len(cmd), - data=map(ord, cmd.ljust(70, '\0'))) + data=[ord(c) for c in cmd.ljust(70, '\0')]) msg.pack(link) ros_msg = mavlink.convert_to_rosmsg(msg) mavlink_pub.publish(ros_msg) @@ -609,7 +609,7 @@ def check_rangefinder(): @check('Boot duration') def check_boot_duration(): - output = subprocess.check_output('systemd-analyze') + output = subprocess.check_output('systemd-analyze').decode() r = re.compile(r'([\d\.]+)s\s*$', flags=re.MULTILINE) duration = float(r.search(output).groups()[0]) if duration > 15: @@ -620,7 +620,7 @@ def check_boot_duration(): def check_cpu_usage(): WHITELIST = 'nodelet', CMD = "top -n 1 -b -i | tail -n +8 | awk '{ printf(\"%-8s\\t%-8s\\t%-8s\\n\", $1, $9, $12); }'" - output = subprocess.check_output(CMD, shell=True) + output = subprocess.check_output(CMD, shell=True).decode() processes = output.split('\n') for process in processes: if not process: @@ -636,7 +636,7 @@ def check_cpu_usage(): def check_clover_service(): try: output = subprocess.check_output('systemctl show -p ActiveState --value clover.service'.split(), - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT).decode() except subprocess.CalledProcessError as e: failure('systemctl returned %s: %s', e.returncode, e.output) return @@ -751,7 +751,7 @@ def check_rpi_health(): # = # In case of `get_throttled`, is a hexadecimal number # with some of the FLAGs OR'ed together - output = subprocess.check_output(['vcgencmd', 'get_throttled']) + output = subprocess.check_output(['vcgencmd', 'get_throttled']).decode() except OSError: failure('could not call vcgencmd binary; not a Raspberry Pi?') return