Mercurial > lcfOS
diff python/st-util.py @ 173:c1d2b6b9f9a7
Rework into passes
author | Windel Bouwman |
---|---|
date | Fri, 19 Apr 2013 12:42:21 +0200 |
parents | 59a9a499e518 |
children | 6259856841a0 |
line wrap: on
line diff
--- a/python/st-util.py Thu Apr 04 17:58:37 2013 +0200 +++ b/python/st-util.py Fri Apr 19 12:42:21 2013 +0200 @@ -3,7 +3,7 @@ import sys from PyQt4.QtCore import * from PyQt4.QtGui import * -import stlink, devices, stm32 +import stlink, devices, stm32, usb from devices import Interface, Device from hexedit import HexEdit @@ -255,9 +255,13 @@ ip = idx.internalPointer() if isinstance(ip, Interface): if not ip.IsOpen: - ip.open() - # Try to get a device: - self.mdl.addDevice(ip.createDevice()) + try: + ip.open() + except usb.UsbError as e: + QMessageBox.critical(self, "Error", 'Error opening interface: "{0}"'.format(e)) + else: + # Try to get a device: + self.mdl.addDevice(ip.createDevice()) if isinstance(ip, Device): self.deviceSelected.emit(ip) def openMenu(self, pt):