diff options
author | Quentin Schulz <quentin.schulz@theobroma-systems.com> | 2021-11-23 18:27:13 +0100 |
---|---|---|
committer | Quentin Schulz <quentin.schulz@theobroma-systems.com> | 2021-11-23 18:27:13 +0100 |
commit | 7d6e4d7326a6076544e533b7bbb318ca94b19922 (patch) | |
tree | 0dcdadea9f0679cd4d3d8f0b86570f6b30ac191b | |
parent | 76ba9d90570ccf8348897ddd66dba99331ecab81 (diff) |
usb-control: switch to python3
Long overdue migration to python3. This was done with 2to3 and barely
tested.
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
-rw-r--r-- | usb-control/command_processor.py | 30 | ||||
-rwxr-xr-x | usb-control/cp2102-cpdebug.py | 2 | ||||
-rwxr-xr-x | usb-control/cp2102-mini-evk.py | 2 | ||||
-rw-r--r-- | usb-control/cp2102_haikou.py | 6 | ||||
-rw-r--r-- | usb-control/cp2102_simple.py | 6 | ||||
-rw-r--r-- | usb-control/cp210x_controller.py | 4 | ||||
-rwxr-xr-x | usb-control/haikou.py | 2 | ||||
-rwxr-xr-x | usb-control/telaviv.py | 2 |
8 files changed, 27 insertions, 27 deletions
diff --git a/usb-control/command_processor.py b/usb-control/command_processor.py index ee03ae2..7d8e513 100644 --- a/usb-control/command_processor.py +++ b/usb-control/command_processor.py @@ -12,9 +12,9 @@ def do_delay(dev): time.sleep(0.3) def do_list(devs): - print "Found %d Baseboard%s:" % (len(devs), "s"[len(devs) == 1:]) + print("Found %d Baseboard%s:" % (len(devs), "s"[len(devs) == 1:])) for idx, dev in enumerate(devs): - print "%d: %s %s" % (idx, dev.serial_number, dev.product) + print("%d: %s %s" % (idx, dev.serial_number, dev.product)) class CommandProcessor: def __init__(self, product_string, options_dict, command_dict): @@ -30,21 +30,21 @@ class CommandProcessor: self.command_dict.update(command_dict) def print_helpstring(self): - print 'Tool to controls power and BIOS disable state' - print 'Synopsis: ' + sys.argv[0] + ' OPTIONS COMMAND(S)' - print 'Options:' - print "\t-h, --help...displays this help text" - print "\t-i, --ignore-product-string...ignore the product string of the device" - print "\t-s SERIAL, --serial SERIAL...specify the serial number of the device" + print('Tool to controls power and BIOS disable state') + print('Synopsis: ' + sys.argv[0] + ' OPTIONS COMMAND(S)') + print('Options:') + print("\t-h, --help...displays this help text") + print("\t-i, --ignore-product-string...ignore the product string of the device") + print("\t-s SERIAL, --serial SERIAL...specify the serial number of the device") if self.options_dict: for o in self.options_dict: (cb, helpstr) = self.options_dict[o] - print "\t" + o + "..." + helpstr - print 'Commands:' + print("\t" + o + "..." + helpstr) + print('Commands:') for c in self.command_dict: (cb, helpstr) = self.command_dict[c] - print "\t" + c + "..." + helpstr - print "" + print("\t" + c + "..." + helpstr) + print("") def validate_commandline(self, argv): self.ignore_product_string = False @@ -70,7 +70,7 @@ class CommandProcessor: elif arg in self.command_dict: self.command_list.append(arg) else: - print "Unkown command " + arg + print("Unkown command " + arg) sys.exit(1) def run(self): @@ -82,7 +82,7 @@ class CommandProcessor: devs = cp210x_controller.find_board_list(self.product_string, self.serialnumber) if len(devs) == 0: - print "No devices found!" + print("No devices found!") sys.exit(2) # List devices if required @@ -92,7 +92,7 @@ class CommandProcessor: # Other commands than 'list' require exactly one device if len(devs) != 1: - print "Please specify target device (found " + str(len(devs)) + " matching devices)" + print("Please specify target device (found " + str(len(devs)) + " matching devices)") sys.exit(3) # Get the one and only device diff --git a/usb-control/cp2102-cpdebug.py b/usb-control/cp2102-cpdebug.py index 802a6e2..b5aca42 100755 --- a/usb-control/cp2102-cpdebug.py +++ b/usb-control/cp2102-cpdebug.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Controls power button and BIOS-disable signal on the diff --git a/usb-control/cp2102-mini-evk.py b/usb-control/cp2102-mini-evk.py index f8b727d..753bd7a 100755 --- a/usb-control/cp2102-mini-evk.py +++ b/usb-control/cp2102-mini-evk.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Controls power button and BIOS-disable signal on the diff --git a/usb-control/cp2102_haikou.py b/usb-control/cp2102_haikou.py index f05b3c1..c94788c 100644 --- a/usb-control/cp2102_haikou.py +++ b/usb-control/cp2102_haikou.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Abstraction layer for Haikou-like control circuits. @@ -61,9 +61,9 @@ def get_bootmode(dev): def do_status(dev): powerstate = get_powerstate(dev) bootmode = get_bootmode(dev) - print "Board is {} ({})".format( + print("Board is {} ({})".format( ("ON" if powerstate == POWERSTATE_ON else "OFF"), - ("BIOS disabled" if bootmode == VALUE_BIOS_DISABLE else "Normal boot (if not overruled by on-board switch)")) + ("BIOS disabled" if bootmode == VALUE_BIOS_DISABLE else "Normal boot (if not overruled by on-board switch)"))) def do_normalboot(dev): set_bootmode(dev, VALUE_BIOS_NORMAL) diff --git a/usb-control/cp2102_simple.py b/usb-control/cp2102_simple.py index c4b2924..587e45d 100644 --- a/usb-control/cp2102_simple.py +++ b/usb-control/cp2102_simple.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Abstraction layer for simple control circuits. @@ -39,9 +39,9 @@ def invert_maskrom(): def do_status(dev): resetstate = cp210x_controller.get_gpio(dev, GPIO_RESET) bootmode = cp210x_controller.get_gpio(dev, GPIO_MASKROM) - print "Board is {} ({})".format( + print("Board is {} ({})".format( ("running" if reset == RESETSTATE_DEASSERTED else "in reset"), - ("normal boot" if bootmode == VALUE_MASKROM_DEASSERTED else "boot to maskrom")) + ("normal boot" if bootmode == VALUE_MASKROM_DEASSERTED else "boot to maskrom"))) def do_reset_assert(dev): cp210x_controller.set_gpio(dev, GPIO_RESET, VALUE_RESET_ASSERT) diff --git a/usb-control/cp210x_controller.py b/usb-control/cp210x_controller.py index b4d9d15..93e5b33 100644 --- a/usb-control/cp210x_controller.py +++ b/usb-control/cp210x_controller.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Low-level library to control the CP210x. """ @@ -70,7 +70,7 @@ def find_board_list(product_string, serialnumber): devs = list(dev_it) return devs - except ValueError, e: + except ValueError as e: if 'langid' in e.message: raise usb.core.USBError(e.message + "\n" + "This may be a permission issue. See: \n" + diff --git a/usb-control/haikou.py b/usb-control/haikou.py index a91ca18..e714337 100755 --- a/usb-control/haikou.py +++ b/usb-control/haikou.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Controls power button and BIOS-disable signal on the diff --git a/usb-control/telaviv.py b/usb-control/telaviv.py index 16e7ffc..41bca15 100755 --- a/usb-control/telaviv.py +++ b/usb-control/telaviv.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Controls power button and BIOS-disable signal on the |