diff -r a71f50b3a503 -r a95800b414b7 src/eric7/MicroPython/WifiDialogs/WifiController.py --- a/src/eric7/MicroPython/WifiDialogs/WifiController.py Sat May 06 16:22:17 2023 +0200 +++ b/src/eric7/MicroPython/WifiDialogs/WifiController.py Sat May 06 19:21:40 2023 +0200 @@ -54,6 +54,9 @@ wifiMenu.addSeparator() wifiMenu.addAction(self.tr("Write WiFi Credentials"), self.__writeCredentials) wifiMenu.addAction(self.tr("Remove WiFi Credentials"), self.__removeCredentials) + if not self.__mpy.getDevice().hasCircuitPython(): + wifiMenu.addAction(self.tr("Enable WebREPL"), self.__enableWebrepl) + wifiMenu.addAction(self.tr("Disable WebREPL"), self.__disableWebrepl) wifiMenu.addSeparator() wifiMenu.addAction(self.tr("Start WiFi Access Point"), self.__startAccessPoint) wifiMenu.addAction( @@ -455,3 +458,71 @@ self.tr("Set Network Time"), msg, ) + + @pyqtSlot() + def __enableWebrepl(self): + """ + Private slot to enable the WebREPL server of the device. + + This will also modify the boot script. + """ + from ..MicroPythonWebreplParametersDialog import ( + MicroPythonWebreplParametersDialog, + ) + + dlg = MicroPythonWebreplParametersDialog() + if dlg.exec() == QDialog.DialogCode.Accepted: + (password,) = dlg.getParameters() + success, error = self.__mpy.getDevice().enableWebrepl(password) + if success: + EricMessageBox.information( + None, + self.tr("Enable WebREPL"), + self.tr( + "<p>The WebREPL server of the device will be activated after a" + " reboot.</p>" + ), + ) + else: + EricMessageBox.critical( + None, + self.tr("Enable WebREPL"), + self.tr( + "<p>The WebREPL server of the device could not be enabled.</p>" + "<p>Reason: {0}</p>" + ).format(error if error else self.tr("unknown")), + ) + + @pyqtSlot() + def __disableWebrepl(self): + """ + Private slot to disable the WebREPL server of the device. + + This will not remove the 'webrepl_cfg.py' file. It will just modify the boot + script. + """ + ok = EricMessageBox.yesNo( + None, + self.tr("Disable WebREPL"), + self.tr("Shall the WebREPL server of the device really be disabled?"), + ) + if ok: + success, error = self.__mpy.getDevice().disableWebrepl() + if success: + EricMessageBox.information( + None, + self.tr("Disable WebREPL"), + self.tr( + "<p>The WebREPL server of the device will not be enabled" + " at boot time anymore.</p>" + ), + ) + else: + EricMessageBox.critical( + None, + self.tr("Disable WebREPL"), + self.tr( + "<p>The WebREPL server of the device could not be disabled." + "</p><p>Reason: {0}</p>" + ).format(error if error else self.tr("unknown")), + )