diff -r 57496966803c -r 6378da868bb0 src/eric7/MicroPython/MicroPythonWidget.py --- a/src/eric7/MicroPython/MicroPythonWidget.py Tue Feb 14 11:09:49 2023 +0100 +++ b/src/eric7/MicroPython/MicroPythonWidget.py Tue Feb 14 18:10:30 2023 +0100 @@ -7,6 +7,7 @@ Module implementing the MicroPython REPL widget. """ +import contextlib import functools import os import re @@ -49,7 +50,7 @@ HAS_QTCHART = False try: - from .MicroPythonCommandsInterface import MicroPythonCommandsInterface + from .MicroPythonDeviceInterface import MicroPythonDeviceInterface HAS_QTSERIALPORT = True except ImportError: @@ -272,7 +273,7 @@ self.__lastDeviceType = None if HAS_QTSERIALPORT: - self.__interface = MicroPythonCommandsInterface(self) + self.__interface = MicroPythonDeviceInterface(self) else: self.__interface = None self.__device = None @@ -461,12 +462,12 @@ if self.__chartWidget is not None: self.__chartWidget.preferencesChanged() - def commandsInterface(self): + def deviceInterface(self): """ - Public method to get a reference to the commands interface object. + Public method to get a reference to the device interface object. @return reference to the commands interface object - @rtype MicroPythonCommandsInterface + @rtype MicroPythonDeviceInterface """ return self.__interface @@ -498,9 +499,7 @@ if deviceType == self.ManualMarker: self.connectButton.setEnabled(bool(self.__unknownPorts)) else: - self.deviceIconLabel.setPixmap( - Devices.getDeviceIcon(deviceType, False) - ) + self.deviceIconLabel.setPixmap(Devices.getDeviceIcon(deviceType, False)) boardName = self.deviceTypeComboBox.itemData(index, self.DeviceBoardRole) vid = self.deviceTypeComboBox.itemData(index, self.DeviceVidRole) @@ -690,7 +689,8 @@ self.__device.setRepl(True) self.replEdit.setFocus(Qt.FocusReason.OtherFocusReason) else: - self.__interface.dataReceived.disconnect(self.__processData) + with contextlib.suppress(TypeError): + self.__interface.dataReceived.disconnect(self.__processData) if not self.chartButton.isChecked() and not self.filesButton.isChecked(): self.__disconnectFromDevice() self.__device.setRepl(False) @@ -1145,9 +1145,7 @@ self.deviceIconLabel.setPixmap( Devices.getDeviceIcon(deviceType, False) ) - self.__device = Devices.getDevice( - deviceType, self, vid, pid - ) + self.__device = Devices.getDevice(deviceType, self, vid, pid) self.__lastPort = port self.__lastDeviceType = deviceType @@ -1370,7 +1368,7 @@ self.__connectToDevice() if self.__connected: self.__fileManagerWidget = MicroPythonFileManagerWidget( - self.__interface, self.__device.supportsLocalFileAccess(), self + self.__device, self ) self.__ui.addSideWidget( @@ -1387,6 +1385,7 @@ else: if self.__fileManagerWidget is not None: self.__fileManagerWidget.stop() + self.__fileManagerWidget.deleteLater() if not self.replButton.isChecked() and not self.chartButton.isChecked(): self.__disconnectFromDevice() @@ -1394,7 +1393,6 @@ self.__device.setFileManager(False) self.__ui.removeSideWidget(self.__fileManagerWidget) - self.__fileManagerWidget.deleteLater() self.__fileManagerWidget = None self.filesButton.setChecked(checked) @@ -1563,7 +1561,7 @@ from .BoardDataDialog import BoardDataDialog try: - boardInfo = self.__interface.getBoardInformation() + boardInfo = self.__device.getBoardInformation() dlg = BoardDataDialog(boardInfo) dlg.exec() @@ -1585,7 +1583,7 @@ and self.__device.getDeviceData()["mpy_name"] == "circuitpython" ) try: - self.__interface.syncTime(self.__device.getDeviceType(), hasCPy=hasCPy) + self.__device.syncTime(self.__device.getDeviceType(), hasCPy=hasCPy) if not quiet: with EricOverridenCursor(): @@ -1611,7 +1609,7 @@ """ if self.__device and self.__device.hasTimeCommands(): try: - dateTimeString = self.__interface.getTime() + dateTimeString = self.__device.getTime() try: date, time = dateTimeString.strip().split(None, 1) return self.tr( @@ -1670,7 +1668,7 @@ localtime = time.strftime("%H:%M:%S", localdatetime) try: - deviceDateTimeString = self.__interface.getTime() + deviceDateTimeString = self.__device.getTime() try: devicedate, devicetime = deviceDateTimeString.strip().split(None, 1) EricMessageBox.information( @@ -1962,7 +1960,7 @@ if self.__connected: try: - moduleNames = self.__interface.getModules() + moduleNames = self.__device.getModules() dlg = ShowModulesDialog( moduleNames, info=self.tr("Plus any modules on the filesystem."),