From 2dc34096a0c15a98d492495d1088c7da11f29c12 Mon Sep 17 00:00:00 2001 From: Riccardo Date: Tue, 24 Sep 2019 22:33:46 -0700 Subject: [PATCH] 2to3 applied --- board/tools/enter_download_mode.py | 2 +- examples/can_bit_transition.py | 4 ++-- examples/can_logger.py | 2 +- python/__init__.py | 14 +++++++------- python/dfu.py | 2 +- python/esptool.py | 6 +++--- python/flash_release.py | 6 +++--- python/isotp.py | 2 +- tests/all_wifi_test.py | 2 +- tests/automated/1_program.py | 2 +- tests/automated/2_usb_to_can.py | 18 +++++++++--------- tests/automated/3_wifi.py | 4 ++-- tests/automated/4_wifi_functionality.py | 4 ++-- tests/automated/5_wifi_udp.py | 6 +++--- tests/automated/6_two_panda.py | 4 ++-- tests/automated/helpers.py | 14 +++++++------- tests/black_loopback_test.py | 2 +- tests/black_white_loopback_test.py | 2 +- tests/black_white_relay_endurance.py | 2 +- tests/black_white_relay_test.py | 2 +- tests/can_printer.py | 4 ++-- tests/debug_console.py | 6 +++--- tests/elm_car_simulator.py | 2 +- tests/elm_throughput.py | 2 +- tests/elm_wifi.py | 4 ++-- tests/loopback_test.py | 6 +++--- tests/safety/test_cadillac.py | 4 ++-- tests/safety/test_chrysler.py | 4 ++-- tests/safety/test_gm.py | 4 ++-- tests/safety/test_honda.py | 4 ++-- tests/safety/test_honda_bosch.py | 4 ++-- tests/safety/test_hyundai.py | 4 ++-- tests/safety/test_subaru.py | 4 ++-- tests/safety/test_toyota.py | 4 ++-- tests/safety/test_toyota_ipas.py | 2 +- tests/safety_replay/test_safety_replay.py | 4 ++-- tests/throughput_test.py | 6 +++--- tests/tucan_loopback.py | 6 +++--- 38 files changed, 87 insertions(+), 87 deletions(-) diff --git a/board/tools/enter_download_mode.py b/board/tools/enter_download_mode.py index d464488b..3dd6545f 100755 --- a/board/tools/enter_download_mode.py +++ b/board/tools/enter_download_mode.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import sys import time diff --git a/examples/can_bit_transition.py b/examples/can_bit_transition.py index 9a54d6ff..1cd72a68 100755 --- a/examples/can_bit_transition.py +++ b/examples/can_bit_transition.py @@ -65,11 +65,11 @@ class Info(): def PrintUnique(log_file, low_range, high_range): # find messages with bits that are always low - start, end = map(float, low_range.split('-')) + start, end = list(map(float, low_range.split('-'))) low = Info() low.load(log_file, start, end) # find messages with bits that are always high - start, end = map(float, high_range.split('-')) + start, end = list(map(float, high_range.split('-'))) high = Info() high.load(log_file, start, end) # print messages that go from low to high diff --git a/examples/can_logger.py b/examples/can_logger.py index 6a1fe280..203023dc 100755 --- a/examples/can_logger.py +++ b/examples/can_logger.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import binascii import csv import sys diff --git a/python/__init__.py b/python/__init__.py index 573d6f15..18e57e8d 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -1,5 +1,5 @@ # python library to interface with panda -from __future__ import print_function + import binascii import struct import hashlib @@ -9,12 +9,12 @@ import os import time import traceback import subprocess -from dfu import PandaDFU -from esptool import ESPROM, CesantaFlasher -from flash_release import flash_release -from update import ensure_st_up_to_date -from serial import PandaSerial -from isotp import isotp_send, isotp_recv +from .dfu import PandaDFU +from .esptool import ESPROM, CesantaFlasher +from .flash_release import flash_release +from .update import ensure_st_up_to_date +from .serial import PandaSerial +from .isotp import isotp_send, isotp_recv __version__ = '0.0.9' diff --git a/python/dfu.py b/python/dfu.py index 02deed47..b3bf05da 100644 --- a/python/dfu.py +++ b/python/dfu.py @@ -1,4 +1,4 @@ -from __future__ import print_function + import os import usb1 import struct diff --git a/python/esptool.py b/python/esptool.py index d97c177c..941c3557 100755 --- a/python/esptool.py +++ b/python/esptool.py @@ -114,7 +114,7 @@ class ESPROM(object): """ Read a SLIP packet from the serial port """ def read(self): - return self._slip_reader.next() + return next(self._slip_reader) """ Write bytes to the serial port while performing SLIP escaping """ def write(self, packet): @@ -991,7 +991,7 @@ def elf2image(args): def read_mac(esp, args): mac = esp.read_mac() - print('MAC: %s' % ':'.join(map(lambda x: '%02x' % x, mac))) + print('MAC: %s' % ':'.join(['%02x' % x for x in mac])) def chip_id(esp, args): @@ -1203,7 +1203,7 @@ def main(): 'version', help='Print esptool version') # internal sanity check - every operation matches a module function of the same name - for operation in subparsers.choices.keys(): + for operation in list(subparsers.choices.keys()): assert operation in globals(), "%s should be a module function" % operation args = parser.parse_args() diff --git a/python/flash_release.py b/python/flash_release.py index 8fb9b644..b50c9b36 100755 --- a/python/flash_release.py +++ b/python/flash_release.py @@ -1,10 +1,10 @@ #!/usr/bin/env python3 -from __future__ import print_function + import sys import time import requests import json -import StringIO +import io def flash_release(path=None, st_serial=None): from panda import Panda, PandaDFU, ESPROM, CesantaFlasher @@ -29,7 +29,7 @@ def flash_release(path=None, st_serial=None): url = json.loads(r.text)['url'] r = requests.get(url) print("Fetching firmware from %s" % url) - path = StringIO.StringIO(r.content) + path = io.StringIO(r.content) zf = ZipFile(path) zf.printdir() diff --git a/python/isotp.py b/python/isotp.py index 09ee180b..891b0bd7 100644 --- a/python/isotp.py +++ b/python/isotp.py @@ -24,7 +24,7 @@ def recv(panda, cnt, addr, nbus): # leave around nmsgs.append((ids, ts, dat, bus)) kmsgs = nmsgs[-256:] - return map(str, ret) + return list(map(str, ret)) def isotp_recv_subaddr(panda, addr, bus, sendaddr, subaddr): msg = recv(panda, 1, addr, bus)[0] diff --git a/tests/all_wifi_test.py b/tests/all_wifi_test.py index 2c92cd90..85dc173b 100755 --- a/tests/all_wifi_test.py +++ b/tests/all_wifi_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import requests import json -from automated.helpers import _connect_wifi +from .automated.helpers import _connect_wifi from panda import Panda from nose.tools import assert_equal diff --git a/tests/automated/1_program.py b/tests/automated/1_program.py index 6b8a3ad4..944db18d 100644 --- a/tests/automated/1_program.py +++ b/tests/automated/1_program.py @@ -1,6 +1,6 @@ import os from panda import Panda -from helpers import panda_type_to_serial, test_white_and_grey, test_all_pandas, panda_connect_and_init +from .helpers import panda_type_to_serial, test_white_and_grey, test_all_pandas, panda_connect_and_init @test_all_pandas @panda_connect_and_init diff --git a/tests/automated/2_usb_to_can.py b/tests/automated/2_usb_to_can.py index f0411b32..eba421e5 100644 --- a/tests/automated/2_usb_to_can.py +++ b/tests/automated/2_usb_to_can.py @@ -1,10 +1,10 @@ -from __future__ import print_function + import os import sys import time from panda import Panda from nose.tools import assert_equal, assert_less, assert_greater -from helpers import SPEED_NORMAL, SPEED_GMLAN, time_many_sends, test_white_and_grey, panda_type_to_serial, test_all_pandas, panda_connect_and_init +from .helpers import SPEED_NORMAL, SPEED_GMLAN, time_many_sends, test_white_and_grey, panda_type_to_serial, test_all_pandas, panda_connect_and_init @test_all_pandas @panda_connect_and_init @@ -30,8 +30,8 @@ def test_can_loopback(p): # confirm receive both on loopback and send receipt time.sleep(0.05) r = p.can_recv() - sr = filter(lambda x: x[3] == 0x80 | bus, r) - lb = filter(lambda x: x[3] == bus, r) + sr = [x for x in r if x[3] == 0x80 | bus] + lb = [x for x in r if x[3] == bus] assert len(sr) == 1 assert len(lb) == 1 @@ -67,7 +67,7 @@ def test_reliability(p): p.set_can_loopback(True) p.set_can_speed_kbps(0, 1000) - addrs = range(100, 100+MSG_COUNT) + addrs = list(range(100, 100+MSG_COUNT)) ts = [(j, 0, "\xaa"*8, 0) for j in addrs] # 100 loops @@ -80,11 +80,11 @@ def test_reliability(p): while len(r) < 200 and (time.time() - st) < 0.5: r.extend(p.can_recv()) - sent_echo = filter(lambda x: x[3] == 0x80, r) - loopback_resp = filter(lambda x: x[3] == 0, r) + sent_echo = [x for x in r if x[3] == 0x80] + loopback_resp = [x for x in r if x[3] == 0] - assert_equal(sorted(map(lambda x: x[0], loopback_resp)), addrs) - assert_equal(sorted(map(lambda x: x[0], sent_echo)), addrs) + assert_equal(sorted([x[0] for x in loopback_resp]), addrs) + assert_equal(sorted([x[0] for x in sent_echo]), addrs) assert_equal(len(r), 200) # take sub 20ms diff --git a/tests/automated/3_wifi.py b/tests/automated/3_wifi.py index 2e9c81f3..f57dbbd0 100644 --- a/tests/automated/3_wifi.py +++ b/tests/automated/3_wifi.py @@ -1,8 +1,8 @@ -from __future__ import print_function + import os import time from panda import Panda -from helpers import connect_wifi, test_white, test_all_pandas, panda_type_to_serial, panda_connect_and_init +from .helpers import connect_wifi, test_white, test_all_pandas, panda_type_to_serial, panda_connect_and_init import requests @test_all_pandas diff --git a/tests/automated/4_wifi_functionality.py b/tests/automated/4_wifi_functionality.py index ee9857d0..67cce4bf 100644 --- a/tests/automated/4_wifi_functionality.py +++ b/tests/automated/4_wifi_functionality.py @@ -1,7 +1,7 @@ -from __future__ import print_function + import time from panda import Panda -from helpers import time_many_sends, connect_wifi, test_white, panda_type_to_serial +from .helpers import time_many_sends, connect_wifi, test_white, panda_type_to_serial from nose.tools import timed, assert_equal, assert_less, assert_greater @test_white diff --git a/tests/automated/5_wifi_udp.py b/tests/automated/5_wifi_udp.py index 8b62cf08..642d8f02 100644 --- a/tests/automated/5_wifi_udp.py +++ b/tests/automated/5_wifi_udp.py @@ -1,7 +1,7 @@ -from __future__ import print_function + import sys import time -from helpers import time_many_sends, connect_wifi, test_white, panda_type_to_serial +from .helpers import time_many_sends, connect_wifi, test_white, panda_type_to_serial from panda import Panda, PandaWifiStreaming from nose.tools import timed, assert_equal, assert_less, assert_greater @@ -54,7 +54,7 @@ def test_udp_doesnt_drop(serials=None): missing = True while len(r) > 0: r = p.can_recv() - r = filter(lambda x: x[3] == bus and x[0] == msg_id, r) + r = [x for x in r if x[3] == bus and x[0] == msg_id] if len(r) > 0: missing = False usb_ok_cnt += len(r) diff --git a/tests/automated/6_two_panda.py b/tests/automated/6_two_panda.py index 8b308ce5..d15f98ee 100644 --- a/tests/automated/6_two_panda.py +++ b/tests/automated/6_two_panda.py @@ -1,10 +1,10 @@ -from __future__ import print_function + import os import time import random from panda import Panda from nose.tools import assert_equal, assert_less, assert_greater -from helpers import time_many_sends, test_two_panda, test_two_black_panda, panda_type_to_serial, clear_can_buffers, panda_connect_and_init +from .helpers import time_many_sends, test_two_panda, test_two_black_panda, panda_type_to_serial, clear_can_buffers, panda_connect_and_init @test_two_panda @panda_type_to_serial diff --git a/tests/automated/helpers.py b/tests/automated/helpers.py index 651dc44f..370e696d 100644 --- a/tests/automated/helpers.py +++ b/tests/automated/helpers.py @@ -4,7 +4,7 @@ import time import random import subprocess import requests -import thread +import _thread from functools import wraps from panda import Panda from nose.tools import timed, assert_equal, assert_less, assert_greater @@ -75,7 +75,7 @@ def _connect_wifi(dongle_id, pw, insecure_okay=False): print("WIFI: scanning %d" % cnt) os.system("iwlist %s scanning > /dev/null" % wlan_interface) os.system("nmcli device wifi rescan") - wifi_scan = filter(lambda x: ssid in x, subprocess.check_output(["nmcli","dev", "wifi", "list"]).split("\n")) + wifi_scan = [x for x in subprocess.check_output(["nmcli","dev", "wifi", "list"]).split("\n") if ssid in x] if len(wifi_scan) != 0: break time.sleep(0.1) @@ -153,11 +153,11 @@ def time_many_sends(p, bus, precv=None, msg_count=100, msg_id=None, two_pandas=F while len(r_echo) < r_echo_len_exected and (time.time() - st) < 10: r_echo.extend(p.can_recv()) - sent_echo = filter(lambda x: x[3] == 0x80 | bus and x[0] == msg_id, r) - sent_echo.extend(filter(lambda x: x[3] == 0x80 | bus and x[0] == msg_id, r_echo)) - resp = filter(lambda x: x[3] == bus and x[0] == msg_id, r) + sent_echo = [x for x in r if x[3] == 0x80 | bus and x[0] == msg_id] + sent_echo.extend([x for x in r_echo if x[3] == 0x80 | bus and x[0] == msg_id]) + resp = [x for x in r if x[3] == bus and x[0] == msg_id] - leftovers = filter(lambda x: (x[3] != 0x80 | bus and x[3] != bus) or x[0] != msg_id, r) + leftovers = [x for x in r if (x[3] != 0x80 | bus and x[3] != bus) or x[0] != msg_id] assert_equal(len(leftovers), 0) assert_equal(len(resp), msg_count) @@ -230,7 +230,7 @@ def panda_connect_and_init(fn): for bus, speed in [(0, SPEED_NORMAL), (1, SPEED_NORMAL), (2, SPEED_NORMAL), (3, SPEED_GMLAN)]: panda.set_can_speed_kbps(bus, speed) clear_can_buffers(panda) - thread.start_new_thread(heartbeat_thread, (panda,)) + _thread.start_new_thread(heartbeat_thread, (panda,)) # Run test function ret = fn(*pandas, **kwargs) diff --git a/tests/black_loopback_test.py b/tests/black_loopback_test.py index 61076eb1..725358aa 100755 --- a/tests/black_loopback_test.py +++ b/tests/black_loopback_test.py @@ -4,7 +4,7 @@ # Tests all buses, including OBD CAN, which is on the same bus as CAN0 in this test. # To be sure, the test should be run with both harness orientations -from __future__ import print_function + import os import sys import time diff --git a/tests/black_white_loopback_test.py b/tests/black_white_loopback_test.py index 332158ba..a4df4e50 100755 --- a/tests/black_white_loopback_test.py +++ b/tests/black_white_loopback_test.py @@ -4,7 +4,7 @@ # Tests all buses, including OBD CAN, which is on the same bus as CAN0 in this test. # To be sure, the test should be run with both harness orientations -from __future__ import print_function + import os import sys import time diff --git a/tests/black_white_relay_endurance.py b/tests/black_white_relay_endurance.py index 71cdcfff..3041aa8c 100755 --- a/tests/black_white_relay_endurance.py +++ b/tests/black_white_relay_endurance.py @@ -4,7 +4,7 @@ # Tests all buses, including OBD CAN, which is on the same bus as CAN0 in this test. # To be sure, the test should be run with both harness orientations -from __future__ import print_function + import os import sys import time diff --git a/tests/black_white_relay_test.py b/tests/black_white_relay_test.py index 8ff1a0bf..65877dc2 100755 --- a/tests/black_white_relay_test.py +++ b/tests/black_white_relay_test.py @@ -3,7 +3,7 @@ # Relay test with loopback between black panda (+ harness and power) and white/grey panda # Tests the relay switching multiple times / second by looking at the buses on which loop occurs. -from __future__ import print_function + import os import sys import time diff --git a/tests/can_printer.py b/tests/can_printer.py index 58388bc5..ae22a417 100755 --- a/tests/can_printer.py +++ b/tests/can_printer.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import os import sys import time @@ -30,7 +30,7 @@ def can_printer(): if sec_since_boot() - lp > 0.1: dd = chr(27) + "[2J" dd += "%5.2f\n" % (sec_since_boot() - start) - for k,v in sorted(zip(msgs.keys(), map(lambda x: binascii.hexlify(x[-1]), msgs.values()))): + for k,v in sorted(zip(list(msgs.keys()), [binascii.hexlify(x[-1]) for x in list(msgs.values())])): dd += "%s(%6d) %s\n" % ("%04X(%4d)" % (k,k),len(msgs[k]), v) print(dd) lp = sec_since_boot() diff --git a/tests/debug_console.py b/tests/debug_console.py index 5f6ecd64..0d0f8559 100755 --- a/tests/debug_console.py +++ b/tests/debug_console.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import os import sys import time @@ -19,9 +19,9 @@ if __name__ == "__main__": serials = Panda.list() if os.getenv("SERIAL"): - serials = filter(lambda x: x==os.getenv("SERIAL"), serials) + serials = [x for x in serials if x==os.getenv("SERIAL")] - pandas = list(map(lambda x: Panda(x, claim=claim), serials)) + pandas = list([Panda(x, claim=claim) for x in serials]) if not len(pandas): sys.exit("no pandas found") diff --git a/tests/elm_car_simulator.py b/tests/elm_car_simulator.py index 56aa696d..ffb30966 100755 --- a/tests/elm_car_simulator.py +++ b/tests/elm_car_simulator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """Used to Reverse/Test ELM protocol auto detect and OBD message response without a car.""" -from __future__ import print_function + import sys import os import struct diff --git a/tests/elm_throughput.py b/tests/elm_throughput.py index 07c406c6..2895b092 100755 --- a/tests/elm_throughput.py +++ b/tests/elm_throughput.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import socket import threading import select diff --git a/tests/elm_wifi.py b/tests/elm_wifi.py index f5a88498..fecb1d09 100644 --- a/tests/elm_wifi.py +++ b/tests/elm_wifi.py @@ -1,4 +1,4 @@ -from __future__ import print_function + import os import sys import time @@ -8,7 +8,7 @@ import pytest import struct sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) -import elm_car_simulator +from . import elm_car_simulator sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..")) from panda import Panda diff --git a/tests/loopback_test.py b/tests/loopback_test.py index 0101d767..02c8d2cd 100755 --- a/tests/loopback_test.py +++ b/tests/loopback_test.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import os import sys import time @@ -29,14 +29,14 @@ def run_test(sleep_duration): run_test_w_pandas(pandas, sleep_duration) def run_test_w_pandas(pandas, sleep_duration): - h = list(map(lambda x: Panda(x), pandas)) + h = list([Panda(x) for x in pandas]) print("H", h) for hh in h: hh.set_safety_mode(Panda.SAFETY_ALLOUTPUT) # test both directions - for ho in permutations(range(len(h)), r=2): + for ho in permutations(list(range(len(h))), r=2): print("***************** TESTING", ho) panda0, panda1 = h[ho[0]], h[ho[1]] diff --git a/tests/safety/test_cadillac.py b/tests/safety/test_cadillac.py index 352acb6d..6ae27550 100644 --- a/tests/safety/test_cadillac.py +++ b/tests/safety/test_cadillac.py @@ -183,8 +183,8 @@ class TestCadillacSafety(unittest.TestCase): def test_fwd_hook(self): # nothing allowed - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) + buss = list(range(0x0, 0x3)) + msgs = list(range(0x1, 0x800)) for b in buss: for m in msgs: diff --git a/tests/safety/test_chrysler.py b/tests/safety/test_chrysler.py index 3989e98b..ff1776c3 100755 --- a/tests/safety/test_chrysler.py +++ b/tests/safety/test_chrysler.py @@ -181,8 +181,8 @@ class TestChryslerSafety(unittest.TestCase): self.assertEqual(0, self.safety.get_chrysler_torque_meas_min()) def test_fwd_hook(self): - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) + buss = list(range(0x0, 0x3)) + msgs = list(range(0x1, 0x800)) chrysler_camera_detected = [0, 1] for ccd in chrysler_camera_detected: diff --git a/tests/safety/test_gm.py b/tests/safety/test_gm.py index cd664a64..3b81deff 100644 --- a/tests/safety/test_gm.py +++ b/tests/safety/test_gm.py @@ -282,8 +282,8 @@ class TestGmSafety(unittest.TestCase): def test_fwd_hook(self): # nothing allowed - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) + buss = list(range(0x0, 0x3)) + msgs = list(range(0x1, 0x800)) for b in buss: for m in msgs: diff --git a/tests/safety/test_honda.py b/tests/safety/test_honda.py index 3ade53ae..1cbb56ac 100755 --- a/tests/safety/test_honda.py +++ b/tests/safety/test_honda.py @@ -254,8 +254,8 @@ class TestHondaSafety(unittest.TestCase): self.assertTrue(self.safety.safety_tx_hook(self._button_msg(RESUME_BTN, BUTTON_MSG))) def test_fwd_hook(self): - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) + buss = list(range(0x0, 0x3)) + msgs = list(range(0x1, 0x800)) long_controls_allowed = [0, 1] fwd_brake = [False, True] diff --git a/tests/safety/test_honda_bosch.py b/tests/safety/test_honda_bosch.py index 7852a5c3..e0dcfc8d 100755 --- a/tests/safety/test_honda_bosch.py +++ b/tests/safety/test_honda_bosch.py @@ -21,8 +21,8 @@ class TestHondaSafety(unittest.TestCase): return to_send def test_fwd_hook(self): - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) + buss = list(range(0x0, 0x3)) + msgs = list(range(0x1, 0x800)) is_panda_black = self.safety.get_hw_type() == 3 # black panda bus_rdr_cam = 2 if is_panda_black else 1 bus_rdr_car = 0 if is_panda_black else 2 diff --git a/tests/safety/test_hyundai.py b/tests/safety/test_hyundai.py index 2deddf53..b863b545 100644 --- a/tests/safety/test_hyundai.py +++ b/tests/safety/test_hyundai.py @@ -190,8 +190,8 @@ class TestHyundaiSafety(unittest.TestCase): def test_fwd_hook(self): - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) + buss = list(range(0x0, 0x3)) + msgs = list(range(0x1, 0x800)) hyundai_giraffe_switch_2 = [0, 1] self.safety.set_hyundai_camera_bus(2) diff --git a/tests/safety/test_subaru.py b/tests/safety/test_subaru.py index 7afe6be0..9f756771 100644 --- a/tests/safety/test_subaru.py +++ b/tests/safety/test_subaru.py @@ -174,8 +174,8 @@ class TestSubaruSafety(unittest.TestCase): def test_fwd_hook(self): - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) + buss = list(range(0x0, 0x3)) + msgs = list(range(0x1, 0x800)) blocked_msgs = [290, 356, 545, 802] for b in buss: for m in msgs: diff --git a/tests/safety/test_toyota.py b/tests/safety/test_toyota.py index e7c9b601..e2bc2a15 100644 --- a/tests/safety/test_toyota.py +++ b/tests/safety/test_toyota.py @@ -281,8 +281,8 @@ class TestToyotaSafety(unittest.TestCase): def test_fwd_hook(self): - buss = range(0x0, 0x3) - msgs = range(0x1, 0x800) + buss = list(range(0x0, 0x3)) + msgs = list(range(0x1, 0x800)) long_controls_allowed = [0, 1] toyota_camera_forwarded = [0, 1] diff --git a/tests/safety/test_toyota_ipas.py b/tests/safety/test_toyota_ipas.py index 9e163e64..cc74d3a1 100644 --- a/tests/safety/test_toyota_ipas.py +++ b/tests/safety/test_toyota_ipas.py @@ -135,7 +135,7 @@ class TestToyotaSafety(unittest.TestCase): # test angle cmd too far from actual angle_refs = [-10, 10] - deltas = range(-2, 3) + deltas = list(range(-2, 3)) expected_results = [False, True, True, True, False] for a in angle_refs: diff --git a/tests/safety_replay/test_safety_replay.py b/tests/safety_replay/test_safety_replay.py index ff23e016..70987371 100755 --- a/tests/safety_replay/test_safety_replay.py +++ b/tests/safety_replay/test_safety_replay.py @@ -3,8 +3,8 @@ import os import requests -from helpers import safety_modes -from replay_drive import replay_drive +from .helpers import safety_modes +from .replay_drive import replay_drive from tools.lib.logreader import LogReader BASE_URL = "https://commadataci.blob.core.windows.net/openpilotci/" diff --git a/tests/throughput_test.py b/tests/throughput_test.py index 0bda0326..69b06c76 100755 --- a/tests/throughput_test.py +++ b/tests/throughput_test.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import os import sys import struct @@ -34,7 +34,7 @@ if __name__ == "__main__": p_in.can_recv() BATCH_SIZE = 16 - for a in tqdm(range(0, 10000, BATCH_SIZE)): + for a in tqdm(list(range(0, 10000, BATCH_SIZE))): for b in range(0, BATCH_SIZE): msg = b"\xaa"*4 + struct.pack("I", a+b) if a%1 == 0: @@ -61,4 +61,4 @@ if __name__ == "__main__": if len(set_out - set_in): print("MISSING %d" % len(set_out - set_in)) if len(set_out - set_in) < 256: - print(map(hex, sorted(list(set_out - set_in)))) + print(list(map(hex, sorted(list(set_out - set_in))))) diff --git a/tests/tucan_loopback.py b/tests/tucan_loopback.py index dbde2735..1b5ed016 100755 --- a/tests/tucan_loopback.py +++ b/tests/tucan_loopback.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import os import sys import time @@ -29,14 +29,14 @@ def run_test(sleep_duration): run_test_w_pandas(pandas, sleep_duration) def run_test_w_pandas(pandas, sleep_duration): - h = list(map(lambda x: Panda(x), pandas)) + h = list([Panda(x) for x in pandas]) print("H", h) for hh in h: hh.set_controls_allowed(True) # test both directions - for ho in permutations(range(len(h)), r=2): + for ho in permutations(list(range(len(h))), r=2): print("***************** TESTING", ho) panda0, panda1 = h[ho[0]], h[ho[1]]