366 """ |
366 """ |
367 Private slot to show the firmware version of the connected device and the |
367 Private slot to show the firmware version of the connected device and the |
368 available firmware version. |
368 available firmware version. |
369 """ |
369 """ |
370 if self.microPython.isConnected(): |
370 if self.microPython.isConnected(): |
371 interface = self.microPython.commandsInterface() |
371 if self._deviceData["mpy_name"] == "micropython": |
372 if interface is not None: |
372 url = QUrl(FirmwareGithubUrls["micropython"]) |
373 impInfo = interface.getImplementation() |
373 elif self._deviceData["mpy_name"] == "circuitpython": |
374 if impInfo["name"] != "micropython": |
374 url = QUrl(FirmwareGithubUrls["circuitpython"]) |
375 EricMessageBox.critical( |
375 else: |
376 None, |
376 EricMessageBox.critical( |
377 self.tr("Show MicroPython Versions"), |
377 None, |
378 self.tr( |
378 self.tr("Show MicroPython Versions"), |
379 """The firmware of the connected device cannot be""" |
379 self.tr( |
380 """ determined or the board does not run MicroPython.""" |
380 """The firmware of the connected device cannot be""" |
381 """ Aborting...""" |
381 """ determined or the board does not run MicroPython""" |
382 ), |
382 """ or CircuitPython. Aborting...""" |
383 ) |
383 ), |
384 else: |
384 ) |
385 ui = ericApp().getObject("UserInterface") |
385 return |
386 request = QNetworkRequest(QUrl(FirmwareGithubUrls["micropython"])) |
386 |
387 reply = ui.networkAccessManager().head(request) |
387 ui = ericApp().getObject("UserInterface") |
388 reply.finished.connect( |
388 request = QNetworkRequest(url) |
389 lambda: self.__firmwareVersionResponse(reply, impInfo) |
389 reply = ui.networkAccessManager().head(request) |
390 ) |
390 reply.finished.connect(lambda: self.__firmwareVersionResponse(reply)) |
391 |
391 |
392 def __firmwareVersionResponse(self, reply, implementation): |
392 def __firmwareVersionResponse(self, reply): |
393 """ |
393 """ |
394 Private method handling the response of the latest version request. |
394 Private method handling the response of the latest version request. |
395 |
395 |
396 @param reply reference to the reply object |
396 @param reply reference to the reply object |
397 @type QNetworkReply |
397 @type QNetworkReply |
398 @param implementation dictionary containing the implementation data of the |
|
399 connected device |
|
400 @type dict |
|
401 """ |
398 """ |
402 latestUrl = reply.url().toString() |
399 latestUrl = reply.url().toString() |
403 tag = latestUrl.rsplit("/", 1)[-1] |
400 tag = latestUrl.rsplit("/", 1)[-1] |
404 while tag and not tag[0].isdecimal(): |
401 while tag and not tag[0].isdecimal(): |
405 # get rid of leading non-decimal characters |
402 # get rid of leading non-decimal characters |
406 tag = tag[1:] |
403 tag = tag[1:] |
407 latestVersion = Globals.versionToTuple(tag) |
404 latestVersion = Globals.versionToTuple(tag) |
408 |
405 |
409 if implementation["version"] == "unknown": |
406 if self._deviceData["mpy_version"] == "unknown": |
410 currentVersionStr = self.tr("unknown") |
407 currentVersionStr = self.tr("unknown") |
411 currentVersion = (0, 0, 0) |
408 currentVersion = (0, 0, 0) |
412 else: |
409 else: |
413 currentVersionStr = implementation["version"] |
410 currentVersionStr = self._deviceData["mpy_version"] |
414 currentVersion = Globals.versionToTuple(currentVersionStr) |
411 currentVersion = Globals.versionToTuple(currentVersionStr) |
415 |
412 |
|
413 if self._deviceData["mpy_name"] == "circuitpython": |
|
414 kind = "CircuitPython" |
|
415 elif self._deviceData["mpy_name"] == "micropython": |
|
416 kind = "MicroPython" |
|
417 |
416 msg = self.tr( |
418 msg = self.tr( |
417 "<h4>MicroPython Version Information</h4>" |
419 "<h4>{0} Version Information</h4>" |
418 "<table>" |
420 "<table>" |
419 "<tr><td>Installed:</td><td>{0}</td></tr>" |
421 "<tr><td>Installed:</td><td>{1}</td></tr>" |
420 "<tr><td>Available:</td><td>{1}</td></tr>" |
422 "<tr><td>Available:</td><td>{2}</td></tr>" |
421 "</table>" |
423 "</table>" |
422 ).format(currentVersionStr, tag) |
424 ).format(kind, currentVersionStr, tag) |
423 if currentVersion < latestVersion: |
425 if currentVersion < latestVersion: |
424 msg += self.tr("<p><b>Update available!</b></p>") |
426 msg += self.tr("<p><b>Update available!</b></p>") |
425 |
427 |
426 EricMessageBox.information( |
428 EricMessageBox.information( |
427 None, |
429 None, |
428 self.tr("MicroPython Version"), |
430 self.tr("{0} Version").format(kind), |
429 msg, |
431 msg, |
430 ) |
432 ) |
431 |
433 |
432 @pyqtSlot() |
434 @pyqtSlot() |
433 def __showChipID(self): |
435 def __showChipID(self): |