Mercurial > lcfOS
comparison 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 |
comparison
equal
deleted
inserted
replaced
172:5a7d37d615ee | 173:c1d2b6b9f9a7 |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 import sys | 3 import sys |
4 from PyQt4.QtCore import * | 4 from PyQt4.QtCore import * |
5 from PyQt4.QtGui import * | 5 from PyQt4.QtGui import * |
6 import stlink, devices, stm32 | 6 import stlink, devices, stm32, usb |
7 from devices import Interface, Device | 7 from devices import Interface, Device |
8 from hexedit import HexEdit | 8 from hexedit import HexEdit |
9 | 9 |
10 class InformationDialog(QDialog): | 10 class InformationDialog(QDialog): |
11 def __init__(self, parent): | 11 def __init__(self, parent): |
253 def openItem(self, idx): | 253 def openItem(self, idx): |
254 if idx.isValid(): | 254 if idx.isValid(): |
255 ip = idx.internalPointer() | 255 ip = idx.internalPointer() |
256 if isinstance(ip, Interface): | 256 if isinstance(ip, Interface): |
257 if not ip.IsOpen: | 257 if not ip.IsOpen: |
258 ip.open() | 258 try: |
259 # Try to get a device: | 259 ip.open() |
260 self.mdl.addDevice(ip.createDevice()) | 260 except usb.UsbError as e: |
261 QMessageBox.critical(self, "Error", 'Error opening interface: "{0}"'.format(e)) | |
262 else: | |
263 # Try to get a device: | |
264 self.mdl.addDevice(ip.createDevice()) | |
261 if isinstance(ip, Device): | 265 if isinstance(ip, Device): |
262 self.deviceSelected.emit(ip) | 266 self.deviceSelected.emit(ip) |
263 def openMenu(self, pt): | 267 def openMenu(self, pt): |
264 idx = self.indexAt(pt) | 268 idx = self.indexAt(pt) |
265 menu = QMenu() | 269 menu = QMenu() |