diff --git a/scripts/dfu.py b/scripts/dfu.py index 170f2d2..3a6fa75 100644 --- a/scripts/dfu.py +++ b/scripts/dfu.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # dfu.py: Access USB DFU class devices # Copyright (C) 2009 Black Sphere Technologies @@ -62,7 +62,7 @@ DFU_STATUS_ERROR_POR = 0x0d DFU_STATUS_ERROR_UNKNOWN = 0x0e DFU_STATUS_ERROR_STALLEDPKT = 0x0f -class dfu_status(object): +class dfu_status: def __init__(self, buf): self.bStatus = buf[0] self.bwPollTimeout = buf[1] + (buf[2]<<8) + (buf[3]<<16) @@ -70,7 +70,7 @@ class dfu_status(object): self.iString = buf[5] -class dfu_device(object): +class dfu_device: def __init__(self, dev, conf, iface): self.dev = dev self.conf = conf diff --git a/scripts/gdb.py b/scripts/gdb.py index 6c6e02d..7ef525f 100644 --- a/scripts/gdb.py +++ b/scripts/gdb.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # gdb.py: Python module for low level GDB protocol implementation # Copyright (C) 2009 Black Sphere Technologies @@ -152,7 +152,7 @@ class Target: """Read length bytes from target at address addr""" ret = b'' while length: - # print "Read" + # print("Read") packlen = min(length,self.PacketSize//2) self.putpacket(b"m%08X,%08X" % (addr, packlen)) reply = self.getpacket() @@ -292,7 +292,7 @@ class Target: addr = self.offset + self.blocksize * i if data is None: continue - #print "Erasing flash at 0x%X" % (self.offset + self.blocksize*i) + #print("Erasing flash at 0x%X" % (self.offset + self.blocksize*i)) self.target.putpacket(b"vFlashErase:%08X,%08X" % (self.offset + self.blocksize*i, self.blocksize)) if self.target.getpacket() != b'OK': @@ -301,7 +301,7 @@ class Target: while data: d = data[0:980] data = data[len(d):] - #print "Writing %d bytes at 0x%X" % (len(d), addr) + #print("Writing %d bytes at 0x%X" % (len(d), addr)) self.target.putpacket(b"vFlashWrite:%08X:%s" % (addr, d)) addr += len(d) if self.target.getpacket() != b'OK': diff --git a/scripts/get_openocd_nrf51_ids.py b/scripts/get_openocd_nrf51_ids.py index 33bdd60..a141f4f 100755 --- a/scripts/get_openocd_nrf51_ids.py +++ b/scripts/get_openocd_nrf51_ids.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 """Pulls nRF51 IDs from openocd's nrf51.c in a form suitable for pasting into blackmagic's nrf51.c @@ -21,11 +21,11 @@ specdict = {} specs = [] spec = Spec() for line in io.TextIOWrapper(proc.stdout, encoding="utf-8"): - m = re.search('/\*(.*)\*/',line) + m = re.search(r'/\*(.*)\*/',line) if m: lastcomment=m.group(1) - m = re.search('NRF51_DEVICE_DEF\((0x[0-9A-F]*),\s*"(.*)",\s*"(.*)",\s*"(.*)",\s*([0-9]*)\s*\),', line) + m = re.search(r'NRF51_DEVICE_DEF\((0x[0-9A-F]*),\s*"(.*)",\s*"(.*)",\s*"(.*)",\s*([0-9]*)\s*\),', line) if m: spec.hwid = int(m.group(1), base=0) spec.variant = m.group(3) diff --git a/scripts/hexprog.py b/scripts/hexprog.py index 43f9693..0c26e9c 100755 --- a/scripts/hexprog.py +++ b/scripts/hexprog.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # hexprog.py: Python application to flash a target with an Intel hex file # Copyright (C) 2011 Black Sphere Technologies @@ -65,8 +65,8 @@ if __name__ == "__main__": from sys import argv, platform, stdout from getopt import getopt - if platform == "linux2": - print ("\x1b\x5b\x48\x1b\x5b\x32\x4a") # clear terminal screen + if platform == "linux": + print("\x1b\x5b\x48\x1b\x5b\x32\x4a") # clear terminal screen print("Black Magic Probe -- Target Production Programming Tool -- version 1.0") print("Copyright (C) 2011 Black Sphere Technologies") print("License GPLv3+: GNU GPL version 3 or later ") diff --git a/scripts/stm32_mem.py b/scripts/stm32_mem.py index 9f47df3..40d8bd9 100755 --- a/scripts/stm32_mem.py +++ b/scripts/stm32_mem.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # stm32_mem.py: STM32 memory access using USB DFU class # Copyright (C) 2011 Black Sphere Technologies