412 """ |
412 """ |
413 Private slot to show the firmware version of the connected device and the |
413 Private slot to show the firmware version of the connected device and the |
414 available firmware version. |
414 available firmware version. |
415 """ |
415 """ |
416 if self.microPython.isConnected(): |
416 if self.microPython.isConnected(): |
417 interface = self.microPython.commandsInterface() |
417 if self._deviceData["mpy_name"] != "micropython": |
418 if interface is not None: |
418 EricMessageBox.critical( |
419 impInfo = interface.getImplementation() |
419 None, |
420 if impInfo["name"] != "micropython": |
420 self.tr("Show MicroPython Versions"), |
421 EricMessageBox.critical( |
421 self.tr( |
422 None, |
422 """The firmware of the connected device cannot be""" |
423 self.tr("Show MicroPython Versions"), |
423 """ determined or the board does not run MicroPython.""" |
424 self.tr( |
424 """ Aborting...""" |
425 """The firmware of the connected device cannot be""" |
425 ), |
426 """ determined or the board does not run MicroPython.""" |
426 ) |
427 """ Aborting...""" |
427 else: |
428 ), |
428 ui = ericApp().getObject("UserInterface") |
429 ) |
429 request = QNetworkRequest(QUrl(FirmwareGithubUrls["micropython"])) |
430 else: |
430 reply = ui.networkAccessManager().head(request) |
431 ui = ericApp().getObject("UserInterface") |
431 reply.finished.connect(lambda: self.__firmwareVersionResponse(reply)) |
432 request = QNetworkRequest(QUrl(FirmwareGithubUrls["micropython"])) |
432 |
433 reply = ui.networkAccessManager().head(request) |
433 def __firmwareVersionResponse(self, reply): |
434 reply.finished.connect( |
|
435 lambda: self.__firmwareVersionResponse(reply, impInfo) |
|
436 ) |
|
437 |
|
438 def __firmwareVersionResponse(self, reply, implementation): |
|
439 """ |
434 """ |
440 Private method handling the response of the latest version request. |
435 Private method handling the response of the latest version request. |
441 |
436 |
442 @param reply reference to the reply object |
437 @param reply reference to the reply object |
443 @type QNetworkReply |
438 @type QNetworkReply |
444 @param implementation dictionary containing the implementation data of the |
|
445 connected device |
|
446 @type dict |
|
447 """ |
439 """ |
448 latestUrl = reply.url().toString() |
440 latestUrl = reply.url().toString() |
449 tag = latestUrl.rsplit("/", 1)[-1] |
441 tag = latestUrl.rsplit("/", 1)[-1] |
450 while tag and not tag[0].isdecimal(): |
442 while tag and not tag[0].isdecimal(): |
451 # get rid of leading non-decimal characters |
443 # get rid of leading non-decimal characters |
452 tag = tag[1:] |
444 tag = tag[1:] |
453 latestVersion = Globals.versionToTuple(tag) |
445 latestVersion = Globals.versionToTuple(tag) |
454 |
446 |
455 if implementation["version"] == "unknown": |
447 if self._deviceData["mpy_version"] == "unknown": |
456 currentVersionStr = self.tr("unknown") |
448 currentVersionStr = self.tr("unknown") |
457 currentVersion = (0, 0, 0) |
449 currentVersion = (0, 0, 0) |
458 else: |
450 else: |
459 currentVersionStr = implementation["version"] |
451 currentVersionStr = self._deviceData["mpy_version"] |
460 currentVersion = Globals.versionToTuple(currentVersionStr) |
452 currentVersion = Globals.versionToTuple(currentVersionStr) |
461 |
453 |
462 msg = self.tr( |
454 msg = self.tr( |
463 "<h4>MicroPython Version Information</h4>" |
455 "<h4>MicroPython Version Information</h4>" |
464 "<table>" |
456 "<table>" |
489 ) |
481 ) |
490 # simulate pressing the disconnect button |
482 # simulate pressing the disconnect button |
491 self.microPython.on_connectButton_clicked() |
483 self.microPython.on_connectButton_clicked() |
492 |
484 |
493 |
485 |
494 def createDevice(microPythonWidget, deviceType, vid, pid, boardName): |
486 def createDevice(microPythonWidget, deviceType, vid, pid, boardName, serialNumber): |
495 """ |
487 """ |
496 Function to instantiate a MicroPython device object. |
488 Function to instantiate a MicroPython device object. |
497 |
489 |
498 @param microPythonWidget reference to the main MicroPython widget |
490 @param microPythonWidget reference to the main MicroPython widget |
499 @type MicroPythonWidget |
491 @type MicroPythonWidget |