summaryrefslogtreecommitdiffstatshomepage
path: root/tools
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-10-22 20:27:43 +0100
committerDamien George <damien.p.george@gmail.com>2014-10-22 20:27:43 +0100
commit5fc42a6c9733bd8f165be7fa8d70fb614ae8de53 (patch)
tree49cb80cba53ebac535e07c2e7ca19c50a3a34b67 /tools
parent842210f53a24666206caaff135cc2dbdc259e1e3 (diff)
downloadmicropython-5fc42a6c9733bd8f165be7fa8d70fb614ae8de53.tar.gz
micropython-5fc42a6c9733bd8f165be7fa8d70fb614ae8de53.zip
tools, pydfu: Some fixes to support Python 3.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/pydfu.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/pydfu.py b/tools/pydfu.py
index af805b4ce1..8b4e960eb9 100755
--- a/tools/pydfu.py
+++ b/tools/pydfu.py
@@ -239,7 +239,7 @@ def consume(fmt, data, names):
def cstring(string):
"""Extracts a null-terminated string from a byte array."""
- return string.split('\0', 1)[0]
+ return string.split(b'\0', 1)[0]
def compute_crc(data):
@@ -361,8 +361,8 @@ def get_dfu_devices(*args, **kwargs):
refine the search.
"""
- return usb.core.find(*args, find_all=True,
- custom_match=FilterDFU(), **kwargs)
+ return list(usb.core.find(*args, find_all=True,
+ custom_match=FilterDFU(), **kwargs))
def get_memory_layout(device):
@@ -504,7 +504,11 @@ def main():
list_dfu_devices(idVendor=__VID, idProduct=__PID)
return
- init()
+ try:
+ init()
+ except ValueError as er:
+ print(str(er))
+ sys.exit(1)
if args.mass_erase:
print ("Mass erase...")