src/eric7/MicroPython/PyBoardDevices.py

branch
eric7
changeset 9751
606ac0e26533
parent 9749
5d409223cf3f
child 9752
2b9546c0cbd9
equal deleted inserted replaced
9750:4958dd72c937 9751:606ac0e26533
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
503 @type int 495 @type int
504 @param pid product ID 496 @param pid product ID
505 @type int 497 @type int
506 @param boardName name of the board 498 @param boardName name of the board
507 @type str 499 @type str
500 @param serialNumber serial number of the board
501 @type str
508 @return reference to the instantiated device object 502 @return reference to the instantiated device object
509 @rtype PyBoardDevice 503 @rtype PyBoardDevice
510 """ 504 """
511 return PyBoardDevice(microPythonWidget, deviceType) 505 return PyBoardDevice(microPythonWidget, deviceType)

eric ide

mercurial