src/eric7/MicroPython/WifiDialogs/WifiController.py

branch
mpy_network
changeset 10022
a95800b414b7
parent 9886
1a4f05b0dc00
child 10153
ffe7432f716b
equal deleted inserted replaced
10021:a71f50b3a503 10022:a95800b414b7
52 wifiMenu.addSeparator() 52 wifiMenu.addSeparator()
53 wifiMenu.addAction(self.tr("Scan Networks"), self.__scanNetwork) 53 wifiMenu.addAction(self.tr("Scan Networks"), self.__scanNetwork)
54 wifiMenu.addSeparator() 54 wifiMenu.addSeparator()
55 wifiMenu.addAction(self.tr("Write WiFi Credentials"), self.__writeCredentials) 55 wifiMenu.addAction(self.tr("Write WiFi Credentials"), self.__writeCredentials)
56 wifiMenu.addAction(self.tr("Remove WiFi Credentials"), self.__removeCredentials) 56 wifiMenu.addAction(self.tr("Remove WiFi Credentials"), self.__removeCredentials)
57 if not self.__mpy.getDevice().hasCircuitPython():
58 wifiMenu.addAction(self.tr("Enable WebREPL"), self.__enableWebrepl)
59 wifiMenu.addAction(self.tr("Disable WebREPL"), self.__disableWebrepl)
57 wifiMenu.addSeparator() 60 wifiMenu.addSeparator()
58 wifiMenu.addAction(self.tr("Start WiFi Access Point"), self.__startAccessPoint) 61 wifiMenu.addAction(self.tr("Start WiFi Access Point"), self.__startAccessPoint)
59 wifiMenu.addAction( 62 wifiMenu.addAction(
60 self.tr("Start WiFi Access Point with IP"), self.__startAccessPointIP 63 self.tr("Start WiFi Access Point with IP"), self.__startAccessPointIP
61 ) 64 )
453 EricMessageBox.critical( 456 EricMessageBox.critical(
454 None, 457 None,
455 self.tr("Set Network Time"), 458 self.tr("Set Network Time"),
456 msg, 459 msg,
457 ) 460 )
461
462 @pyqtSlot()
463 def __enableWebrepl(self):
464 """
465 Private slot to enable the WebREPL server of the device.
466
467 This will also modify the boot script.
468 """
469 from ..MicroPythonWebreplParametersDialog import (
470 MicroPythonWebreplParametersDialog,
471 )
472
473 dlg = MicroPythonWebreplParametersDialog()
474 if dlg.exec() == QDialog.DialogCode.Accepted:
475 (password,) = dlg.getParameters()
476 success, error = self.__mpy.getDevice().enableWebrepl(password)
477 if success:
478 EricMessageBox.information(
479 None,
480 self.tr("Enable WebREPL"),
481 self.tr(
482 "<p>The WebREPL server of the device will be activated after a"
483 " reboot.</p>"
484 ),
485 )
486 else:
487 EricMessageBox.critical(
488 None,
489 self.tr("Enable WebREPL"),
490 self.tr(
491 "<p>The WebREPL server of the device could not be enabled.</p>"
492 "<p>Reason: {0}</p>"
493 ).format(error if error else self.tr("unknown")),
494 )
495
496 @pyqtSlot()
497 def __disableWebrepl(self):
498 """
499 Private slot to disable the WebREPL server of the device.
500
501 This will not remove the 'webrepl_cfg.py' file. It will just modify the boot
502 script.
503 """
504 ok = EricMessageBox.yesNo(
505 None,
506 self.tr("Disable WebREPL"),
507 self.tr("Shall the WebREPL server of the device really be disabled?"),
508 )
509 if ok:
510 success, error = self.__mpy.getDevice().disableWebrepl()
511 if success:
512 EricMessageBox.information(
513 None,
514 self.tr("Disable WebREPL"),
515 self.tr(
516 "<p>The WebREPL server of the device will not be enabled"
517 " at boot time anymore.</p>"
518 ),
519 )
520 else:
521 EricMessageBox.critical(
522 None,
523 self.tr("Disable WebREPL"),
524 self.tr(
525 "<p>The WebREPL server of the device could not be disabled."
526 "</p><p>Reason: {0}</p>"
527 ).format(error if error else self.tr("unknown")),
528 )

eric ide

mercurial