scripts: more conversion to Python 3, change the shebang line

This commit is contained in:
Nicolas Schodet 2022-02-08 00:01:38 +01:00 committed by Piotr Esden-Tempski
parent d9cce4d5e8
commit eafc634eba
5 changed files with 14 additions and 14 deletions

View File

@ -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

View File

@ -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':

View File

@ -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)

View File

@ -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,7 +65,7 @@ if __name__ == "__main__":
from sys import argv, platform, stdout
from getopt import getopt
if platform == "linux2":
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")

View File

@ -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