src/eric7/MicroPython/EspDevices.py

branch
eric7
changeset 9751
606ac0e26533
parent 9749
5d409223cf3f
child 9752
2b9546c0cbd9
--- a/src/eric7/MicroPython/EspDevices.py	Thu Feb 09 09:55:57 2023 +0100
+++ b/src/eric7/MicroPython/EspDevices.py	Sat Feb 11 16:59:50 2023 +0100
@@ -368,36 +368,33 @@
         available firmware version.
         """
         if self.microPython.isConnected():
-            interface = self.microPython.commandsInterface()
-            if interface is not None:
-                impInfo = interface.getImplementation()
-                if impInfo["name"] != "micropython":
-                    EricMessageBox.critical(
-                        None,
-                        self.tr("Show MicroPython Versions"),
-                        self.tr(
-                            """The firmware of the connected device cannot be"""
-                            """ determined or the board does not run MicroPython."""
-                            """ Aborting..."""
-                        ),
-                    )
-                else:
-                    ui = ericApp().getObject("UserInterface")
-                    request = QNetworkRequest(QUrl(FirmwareGithubUrls["micropython"]))
-                    reply = ui.networkAccessManager().head(request)
-                    reply.finished.connect(
-                        lambda: self.__firmwareVersionResponse(reply, impInfo)
-                    )
+            if self._deviceData["mpy_name"] == "micropython":
+                url = QUrl(FirmwareGithubUrls["micropython"])
+            elif self._deviceData["mpy_name"] == "circuitpython":
+                url = QUrl(FirmwareGithubUrls["circuitpython"])
+            else:
+                EricMessageBox.critical(
+                    None,
+                    self.tr("Show MicroPython Versions"),
+                    self.tr(
+                        """The firmware of the connected device cannot be"""
+                        """ determined or the board does not run MicroPython"""
+                        """ or CircuitPython. Aborting..."""
+                    ),
+                )
+                return
 
-    def __firmwareVersionResponse(self, reply, implementation):
+            ui = ericApp().getObject("UserInterface")
+            request = QNetworkRequest(url)
+            reply = ui.networkAccessManager().head(request)
+            reply.finished.connect(lambda: self.__firmwareVersionResponse(reply))
+
+    def __firmwareVersionResponse(self, reply):
         """
         Private method handling the response of the latest version request.
 
         @param reply reference to the reply object
         @type QNetworkReply
-        @param implementation dictionary containing the implementation data of the
-            connected device
-        @type dict
         """
         latestUrl = reply.url().toString()
         tag = latestUrl.rsplit("/", 1)[-1]
@@ -406,26 +403,31 @@
             tag = tag[1:]
         latestVersion = Globals.versionToTuple(tag)
 
-        if implementation["version"] == "unknown":
+        if self._deviceData["mpy_version"] == "unknown":
             currentVersionStr = self.tr("unknown")
             currentVersion = (0, 0, 0)
         else:
-            currentVersionStr = implementation["version"]
+            currentVersionStr = self._deviceData["mpy_version"]
             currentVersion = Globals.versionToTuple(currentVersionStr)
 
+        if self._deviceData["mpy_name"] == "circuitpython":
+            kind = "CircuitPython"
+        elif self._deviceData["mpy_name"] == "micropython":
+            kind = "MicroPython"
+
         msg = self.tr(
-            "<h4>MicroPython Version Information</h4>"
+            "<h4>{0} Version Information</h4>"
             "<table>"
-            "<tr><td>Installed:</td><td>{0}</td></tr>"
-            "<tr><td>Available:</td><td>{1}</td></tr>"
+            "<tr><td>Installed:</td><td>{1}</td></tr>"
+            "<tr><td>Available:</td><td>{2}</td></tr>"
             "</table>"
-        ).format(currentVersionStr, tag)
+        ).format(kind, currentVersionStr, tag)
         if currentVersion < latestVersion:
             msg += self.tr("<p><b>Update available!</b></p>")
 
         EricMessageBox.information(
             None,
-            self.tr("MicroPython Version"),
+            self.tr("{0} Version").format(kind),
             msg,
         )
 
@@ -547,7 +549,7 @@
         return Preferences.getMicroPython("MicroPythonFirmwareUrl")
 
 
-def createDevice(microPythonWidget, deviceType, vid, pid, boardName):
+def createDevice(microPythonWidget, deviceType, vid, pid, boardName, serialNumber):
     """
     Function to instantiate a MicroPython device object.
 
@@ -561,6 +563,8 @@
     @type int
     @param boardName name of the board
     @type str
+    @param serialNumber serial number of the board
+    @type str
     @return reference to the instantiated device object
     @rtype EspDevice
     """

eric ide

mercurial