From 8632ead97ef37697fff18fa2c7c377f0849cc4f8 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Mon, 9 May 2022 09:21:41 +0900 Subject: [PATCH 1/7] fix travis: pip install pyyaml==5.4.1 ## latest pyyaml raises TypeError: load() missing 1 required positional argument: 'Loader' --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 945b510..aa56ccf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,8 @@ sudo: true dist: bionic language: python +python: + - "3.6" env: global: - JOB_PATH=/tmp/devel_job @@ -25,6 +27,7 @@ install: # check python3 compatibility - if [ "${CHECK_PYTHON3_COMPILE}" == "true" ]; then python3 -m compileall -x asmach .; exit $?; fi # either install the latest released version of ros_buildfarm + - pip install pyyaml==5.4.1 ## latest pyyaml raises TypeError: load() missing 1 required positional argument: 'Loader' - pip install ros_buildfarm # or checkout a specific branch #- git clone -b master https://github.com/ros-infrastructure/ros_buildfarm /tmp/ros_buildfarm From 9865bc05c2bf60dbfa7a6e4d3fa8c7ca0f226366 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Mon, 9 May 2022 09:29:41 +0900 Subject: [PATCH 2/7] add CHECK_PYTHON2_COMPILE, update python3 check --- .travis.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index aa56ccf..df38b35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,12 +9,18 @@ dist: bionic language: python python: - "3.6" +addons: + apt: + packages: + - python2.7 + - 2to3 env: global: - JOB_PATH=/tmp/devel_job - ABORT_ON_TEST_FAILURE=1 - INDEX_URL=https://raw.githubusercontent.com/ros-infrastructure/ros_buildfarm_config/production/index.yaml matrix: + - CHECK_PYTHON2_COMPILE=true - CHECK_PYTHON3_COMPILE=true - ROS_DISTRO_NAME=indigo OS_NAME=ubuntu OS_CODE_NAME=trusty ARCH=amd64 INDEX_URL=https://raw.githubusercontent.com/ros-infrastructure/ros_buildfarm_config/6a93d17/index.yaml - ROS_DISTRO_NAME=kinetic OS_NAME=ubuntu OS_CODE_NAME=xenial ARCH=amd64 INDEX_URL=https://raw.githubusercontent.com/ros-infrastructure/ros_buildfarm_config/6a93d17/index.yaml @@ -24,8 +30,10 @@ env: # allow_failures: # - env: ROS_DISTRO_NAME=melodic OS_NAME=ubuntu OS_CODE_NAME=bionic ARCH=amd64 install: + # check python2 compatibility + - if [ "${CHECK_PYTHON2_COMPILE}" == "true" ]; then python2 -m compileall .; exit $?; fi # check python3 compatibility - - if [ "${CHECK_PYTHON3_COMPILE}" == "true" ]; then python3 -m compileall -x asmach .; exit $?; fi + - if [ "${CHECK_PYTHON3_COMPILE}" == "true" ]; then bash -c "ret=0; trap 'ret=1' ERR; python3 -m compileall .; 2to3 -w -f except -f execfile -f has_key -f import -f raw_input -f zip .; git diff --exit-code . > /dev/null; echo Exitting with \$ret; exit \$ret"; exit $?; fi # either install the latest released version of ros_buildfarm - pip install pyyaml==5.4.1 ## latest pyyaml raises TypeError: load() missing 1 required positional argument: 'Loader' - pip install ros_buildfarm From e2f3eab9b54134579761b082be8f2c4dd62e432e Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Mon, 9 May 2022 09:31:28 +0900 Subject: [PATCH 3/7] update reository keys for trusty/xenial --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index df38b35..204760b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,6 +49,8 @@ install: - cp -R $TRAVIS_BUILD_DIR $JOB_PATH/ws/src/ # generate the script to run a pre-release job for that target and repo - generate_prerelease_script.py $INDEX_URL $ROS_DISTRO_NAME default $OS_NAME $OS_CODE_NAME $ARCH --output-dir $JOB_PATH + # update keys for trusty/xenial + - set -x; if [ "${OS_CODE_NAME}" = "trusty" ] || [ "${OS_CODE_NAME}" = "xenial" ]; then sed -i /0.key$/a'curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | tee $WORKSPACE/keys/0.key' $JOB_PATH/prerelease_build_*.sh; fi # run the actual job which involves Docker - cd $JOB_PATH; sh ./prerelease.sh -y script: From 6959dd3985176ddb43b7855957f6b7d580fa2e87 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Mon, 9 May 2022 13:16:40 +0900 Subject: [PATCH 4/7] fixup syntax error in python2 after 2to3 migration, there is one use of `print(str, file=...)` after the transition. --- pr2_camera_synchronizer/scripts/plot_multi_trigger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr2_camera_synchronizer/scripts/plot_multi_trigger.py b/pr2_camera_synchronizer/scripts/plot_multi_trigger.py index c5d6561..9bffe8d 100755 --- a/pr2_camera_synchronizer/scripts/plot_multi_trigger.py +++ b/pr2_camera_synchronizer/scripts/plot_multi_trigger.py @@ -1,6 +1,6 @@ #! /usr/bin/env python -from __future__ import with_statement +from __future__ import with_statement, print_function PKG='pr2_camera_synchronizer' import roslib; roslib.load_manifest(PKG) From ca4b4e5e046b8739c2befa1059d4224b12ca4c6d Mon Sep 17 00:00:00 2001 From: Michael Goerner Date: Thu, 5 May 2022 18:11:51 +0000 Subject: [PATCH 5/7] python3 transition --- pr2_computer_monitor/scripts/cpu_monitor.py | 25 ++++++++++++++++----- pr2_computer_monitor/scripts/hd_monitor.py | 8 ++++--- pr2_computer_monitor/scripts/ntp_monitor.py | 2 ++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/pr2_computer_monitor/scripts/cpu_monitor.py b/pr2_computer_monitor/scripts/cpu_monitor.py index 664a13f..66e2589 100755 --- a/pr2_computer_monitor/scripts/cpu_monitor.py +++ b/pr2_computer_monitor/scripts/cpu_monitor.py @@ -72,6 +72,8 @@ def check_ipmi(): stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True) stdout, stderr = p.communicate() + stdout = stdout.decode() + stderr = stderr.decode() retcode = p.returncode if retcode != 0: @@ -105,7 +107,7 @@ def check_ipmi(): if words[0].startswith('CPU') and words[0].strip().endswith('Temp'): if words[1].strip().endswith('degrees C'): tmp = ipmi_val.rstrip(' degrees C').lstrip() - if unicode(tmp).isnumeric(): + if tmp.isnumeric(): temperature = float(tmp) diag_vals.append(KeyValue(key = name + ' (C)', value = tmp)) @@ -133,7 +135,7 @@ def check_ipmi(): diag_vals.append(KeyValue(key = name + ' (C)', value = tmp)) # Give temp warning dev_name = name.split()[0] - if unicode(tmp).isnumeric(): + if tmp.isnumeric(): temperature = float(tmp) if temperature >= 60 and temperature < 75: @@ -153,7 +155,7 @@ def check_ipmi(): if (name.startswith('CPU') and name.endswith('Fan')) or name == 'MB Fan': if ipmi_val.endswith('RPM'): rpm = ipmi_val.rstrip(' RPM').lstrip() - if unicode(rpm).isnumeric(): + if rpm.isnumeric(): if int(rpm) == 0: diag_level = max(diag_level, DiagnosticStatus.ERROR) diag_msgs.append('CPU Fan Off') @@ -197,6 +199,8 @@ def check_core_temps(sys_temp_strings): p = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True) stdout, stderr = p.communicate() + stdout = stdout.decode() + stderr = stderr.decode() retcode = p.returncode if retcode != 0: @@ -207,7 +211,7 @@ def check_core_temps(sys_temp_strings): return diag_vals, diag_msgs, diag_level tmp = stdout.strip() - if unicode(tmp).isnumeric(): + if tmp.isnumeric(): temp = float(tmp) / 1000 diag_vals.append(KeyValue(key = 'Core %d Temp' % index, value = str(temp))) @@ -234,6 +238,8 @@ def check_clock_speed(enforce_speed): stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True) stdout, stderr = p.communicate() + stdout = stdout.decode() + stderr = stderr.decode() retcode = p.returncode if retcode != 0: @@ -251,7 +257,7 @@ def check_clock_speed(enforce_speed): speed = words[1].strip().split('.')[0] # Conversion to float doesn't work with decimal vals.append(KeyValue(key = 'Core %d MHz' % index, value = speed)) - if unicode(speed).isnumeric(): + if speed.isnumeric(): mhz = float(speed) if mhz < 2240 and mhz > 2150: @@ -291,6 +297,8 @@ def check_uptime(load1_threshold, load5_threshold): p = subprocess.Popen('uptime', stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True) stdout, stderr = p.communicate() + stdout = stdout.decode() + stderr = stderr.decode() retcode = p.returncode if retcode != 0: @@ -336,6 +344,7 @@ def check_memory(): stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True) stdout, stderr = p.communicate() + stdout = stdout.decode() retcode = p.returncode if retcode != 0: @@ -386,6 +395,8 @@ def check_mpstat(core_count = -1): stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True) stdout, stderr = p.communicate() + stdout = stdout.decode() + stderr = stderr.decode() retcode = p.returncode if retcode != 0: @@ -478,6 +489,8 @@ def get_core_temp_names(): stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True) stdout, stderr = p.communicate() + stdout = stdout.decode() + stderr = stderr.decode() retcode = p.returncode if retcode != 0: @@ -622,6 +635,8 @@ def check_nfs_stat(self): stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True) stdout, stderr = p.communicate() + stdout = stdout.decode() + stderr = stderr.decode() retcode = p.returncode if retcode != 0: diff --git a/pr2_computer_monitor/scripts/hd_monitor.py b/pr2_computer_monitor/scripts/hd_monitor.py index 8c582fa..0becd1a 100755 --- a/pr2_computer_monitor/scripts/hd_monitor.py +++ b/pr2_computer_monitor/scripts/hd_monitor.py @@ -80,6 +80,7 @@ def get_hddtemp_data(hostname = 'localhost', port = 7634): newdat = hd_sock.recv(1024) if len(newdat) == 0: break + newdat = newdat.decode() sock_data = sock_data + newdat hd_sock.close() @@ -201,10 +202,10 @@ def check_temps(self): for index in range(0, len(drives)): temp = temps[index] - if not unicode(temp).isnumeric() and drives[index] not in REMOVABLE: + if not temp.isnumeric() and drives[index] not in REMOVABLE: temp_level = DiagnosticStatus.ERROR temp_ok = False - elif not unicode(temp).isnumeric() and drives[index] in REMOVABLE: + elif not temp.isnumeric() and drives[index] in REMOVABLE: temp_level = DiagnosticStatus.OK temp = "Removed" else: @@ -258,6 +259,7 @@ def check_disk_usage(self): p = subprocess.Popen(["df", "-P", "--block-size=1G", self._home_dir], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() + stdout = stdout.decode() retcode = p.returncode if (retcode == 0): @@ -267,7 +269,7 @@ def check_disk_usage(self): for row in stdout.split('\n'): if len(row.split()) < 2: continue - if not unicode(row.split()[1]).isnumeric() or float(row.split()[1]) < 10: # Ignore small drives + if not row.split()[1].isnumeric() or float(row.split()[1]) < 10: # Ignore small drives continue row_count += 1 diff --git a/pr2_computer_monitor/scripts/ntp_monitor.py b/pr2_computer_monitor/scripts/ntp_monitor.py index 1b4b94b..09e2013 100755 --- a/pr2_computer_monitor/scripts/ntp_monitor.py +++ b/pr2_computer_monitor/scripts/ntp_monitor.py @@ -88,6 +88,8 @@ def ntp_monitor(ntp_hostname, offset=500, self_offset=500, diag_hostname=None, p = Popen(["ntpdate", "-q", host], stdout=PIPE, stdin=PIPE, stderr=PIPE) res = p.wait() (o,e) = p.communicate() + o = o.decode() + e = e.decode() except OSError as e: (errno, msg) = e.args if errno == 4: From 41de2ac31d2e835f20c51db6d8696c7a6a7488e6 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Mon, 9 May 2022 13:20:37 +0900 Subject: [PATCH 6/7] run 2to3 -f zip --- pr2_bringup/scripts/calibrate_pr2.py | 2 +- pr2_camera_synchronizer/test/test_classes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pr2_bringup/scripts/calibrate_pr2.py b/pr2_bringup/scripts/calibrate_pr2.py index 455be14..6976a19 100755 --- a/pr2_bringup/scripts/calibrate_pr2.py +++ b/pr2_bringup/scripts/calibrate_pr2.py @@ -369,7 +369,7 @@ def main(): if recalibrate: controller_list = list_controllers() def is_running(c) : return c[1]=='running' - running_controllers = [c[0] for c in filter(is_running, zip(controller_list.controllers, controller_list.state))] + running_controllers = [c[0] for c in filter(is_running, list(zip(controller_list.controllers, controller_list.state)))] print("Running controllers : ", running_controllers) if not switch_controller([], running_controllers, SwitchControllerRequest.STRICT): print("Failed to stop controllers") diff --git a/pr2_camera_synchronizer/test/test_classes.py b/pr2_camera_synchronizer/test/test_classes.py index f3afe49..8330ba2 100755 --- a/pr2_camera_synchronizer/test/test_classes.py +++ b/pr2_camera_synchronizer/test/test_classes.py @@ -45,7 +45,7 @@ def issorted(l): return copy == l def interlace(l1, l2): - l = zip(l1, l2) + l = list(zip(l1, l2)) return list(sum(l, ())) class TestProjector(unittest.TestCase): From b8e37d7f60cfca6ff895ec607a9396fc57e4c9d4 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Mon, 9 May 2022 13:28:38 +0900 Subject: [PATCH 7/7] run 2to3 -f import --- pr2_computer_monitor/src/pr2_computer_monitor/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr2_computer_monitor/src/pr2_computer_monitor/__init__.py b/pr2_computer_monitor/src/pr2_computer_monitor/__init__.py index 306358e..596d917 100644 --- a/pr2_computer_monitor/src/pr2_computer_monitor/__init__.py +++ b/pr2_computer_monitor/src/pr2_computer_monitor/__init__.py @@ -1 +1 @@ -from nvidia_smi_util import gpu_status_to_diag, parse_smi_output, get_gpu_status +from .nvidia_smi_util import gpu_status_to_diag, parse_smi_output, get_gpu_status