9 """ |
9 """ |
10 |
10 |
11 from PyQt6.QtCore import QProcess, pyqtSlot |
11 from PyQt6.QtCore import QProcess, pyqtSlot |
12 from PyQt6.QtWidgets import QDialog |
12 from PyQt6.QtWidgets import QDialog |
13 |
13 |
14 from eric7 import Globals, Preferences |
14 from eric7 import Preferences |
15 from eric7.EricWidgets import EricMessageBox |
15 from eric7.EricWidgets import EricMessageBox |
16 from eric7.EricWidgets.EricApplication import ericApp |
16 from eric7.EricWidgets.EricApplication import ericApp |
17 from eric7.EricWidgets.EricProcessDialog import EricProcessDialog |
17 from eric7.EricWidgets.EricProcessDialog import EricProcessDialog |
|
18 from eric7.SystemUtilities import PythonUtilities |
18 |
19 |
19 from .MicroPythonDevices import MicroPythonDevice |
20 from .MicroPythonDevices import MicroPythonDevice |
20 from .MicroPythonWidget import HAS_QTCHART |
21 from .MicroPythonWidget import HAS_QTCHART |
21 |
22 |
22 |
23 |
182 dlg = EricProcessDialog( |
183 dlg = EricProcessDialog( |
183 self.tr("'esptool erase_flash' Output"), |
184 self.tr("'esptool erase_flash' Output"), |
184 self.tr("Erase Flash"), |
185 self.tr("Erase Flash"), |
185 showProgress=True, |
186 showProgress=True, |
186 ) |
187 ) |
187 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
188 res = dlg.startProcess(PythonUtilities.getPythonExecutable(), flashArgs) |
188 if res: |
189 if res: |
189 dlg.exec() |
190 dlg.exec() |
190 |
191 |
191 @pyqtSlot() |
192 @pyqtSlot() |
192 def __flashMicroPython(self): |
193 def __flashMicroPython(self): |
219 dlg = EricProcessDialog( |
220 dlg = EricProcessDialog( |
220 self.tr("'esptool write_flash' Output"), |
221 self.tr("'esptool write_flash' Output"), |
221 self.tr("Flash MicroPython Firmware"), |
222 self.tr("Flash MicroPython Firmware"), |
222 showProgress=True, |
223 showProgress=True, |
223 ) |
224 ) |
224 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
225 res = dlg.startProcess(PythonUtilities.getPythonExecutable(), flashArgs) |
225 if res: |
226 if res: |
226 dlg.exec() |
227 dlg.exec() |
227 |
228 |
228 @pyqtSlot() |
229 @pyqtSlot() |
229 def __flashAddons(self): |
230 def __flashAddons(self): |
256 dlg = EricProcessDialog( |
257 dlg = EricProcessDialog( |
257 self.tr("'esptool write_flash' Output"), |
258 self.tr("'esptool write_flash' Output"), |
258 self.tr("Flash Additional Firmware"), |
259 self.tr("Flash Additional Firmware"), |
259 showProgress=True, |
260 showProgress=True, |
260 ) |
261 ) |
261 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
262 res = dlg.startProcess(PythonUtilities.getPythonExecutable(), flashArgs) |
262 if res: |
263 if res: |
263 dlg.exec() |
264 dlg.exec() |
264 |
265 |
265 @pyqtSlot() |
266 @pyqtSlot() |
266 def __backupFlash(self): |
267 def __backupFlash(self): |
290 dlg = EricProcessDialog( |
291 dlg = EricProcessDialog( |
291 self.tr("'esptool read_flash' Output"), |
292 self.tr("'esptool read_flash' Output"), |
292 self.tr("Backup Firmware"), |
293 self.tr("Backup Firmware"), |
293 showProgress=True, |
294 showProgress=True, |
294 ) |
295 ) |
295 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
296 res = dlg.startProcess(PythonUtilities.getPythonExecutable(), flashArgs) |
296 if res: |
297 if res: |
297 dlg.exec() |
298 dlg.exec() |
298 |
299 |
299 @pyqtSlot() |
300 @pyqtSlot() |
300 def __restoreFlash(self): |
301 def __restoreFlash(self): |
341 dlg = EricProcessDialog( |
342 dlg = EricProcessDialog( |
342 self.tr("'esptool write_flash' Output"), |
343 self.tr("'esptool write_flash' Output"), |
343 self.tr("Restore Firmware"), |
344 self.tr("Restore Firmware"), |
344 showProgress=True, |
345 showProgress=True, |
345 ) |
346 ) |
346 res = dlg.startProcess(Globals.getPythonExecutable(), flashArgs) |
347 res = dlg.startProcess(PythonUtilities.getPythonExecutable(), flashArgs) |
347 if res: |
348 if res: |
348 dlg.exec() |
349 dlg.exec() |
349 |
350 |
350 @pyqtSlot() |
351 @pyqtSlot() |
351 def __showChipID(self): |
352 def __showChipID(self): |
361 "chip_id", |
362 "chip_id", |
362 ] |
363 ] |
363 dlg = EricProcessDialog( |
364 dlg = EricProcessDialog( |
364 self.tr("'esptool chip_id' Output"), self.tr("Show Chip ID") |
365 self.tr("'esptool chip_id' Output"), self.tr("Show Chip ID") |
365 ) |
366 ) |
366 res = dlg.startProcess(Globals.getPythonExecutable(), args) |
367 res = dlg.startProcess(PythonUtilities.getPythonExecutable(), args) |
367 if res: |
368 if res: |
368 dlg.exec() |
369 dlg.exec() |
369 |
370 |
370 @pyqtSlot() |
371 @pyqtSlot() |
371 def __showFlashID(self): |
372 def __showFlashID(self): |
381 "flash_id", |
382 "flash_id", |
382 ] |
383 ] |
383 dlg = EricProcessDialog( |
384 dlg = EricProcessDialog( |
384 self.tr("'esptool flash_id' Output"), self.tr("Show Flash ID") |
385 self.tr("'esptool flash_id' Output"), self.tr("Show Flash ID") |
385 ) |
386 ) |
386 res = dlg.startProcess(Globals.getPythonExecutable(), args) |
387 res = dlg.startProcess(PythonUtilities.getPythonExecutable(), args) |
387 if res: |
388 if res: |
388 dlg.exec() |
389 dlg.exec() |
389 |
390 |
390 @pyqtSlot() |
391 @pyqtSlot() |
391 def __showMACAddress(self): |
392 def __showMACAddress(self): |
401 "read_mac", |
402 "read_mac", |
402 ] |
403 ] |
403 dlg = EricProcessDialog( |
404 dlg = EricProcessDialog( |
404 self.tr("'esptool read_mac' Output"), self.tr("Show MAC Address") |
405 self.tr("'esptool read_mac' Output"), self.tr("Show MAC Address") |
405 ) |
406 ) |
406 res = dlg.startProcess(Globals.getPythonExecutable(), args) |
407 res = dlg.startProcess(PythonUtilities.getPythonExecutable(), args) |
407 if res: |
408 if res: |
408 dlg.exec() |
409 dlg.exec() |
409 |
410 |
410 @pyqtSlot() |
411 @pyqtSlot() |
411 def __resetDevice(self): |
412 def __resetDevice(self): |
429 "--port", |
430 "--port", |
430 self.microPython.getCurrentPort(), |
431 self.microPython.getCurrentPort(), |
431 "flash_id", |
432 "flash_id", |
432 ] |
433 ] |
433 proc = QProcess() |
434 proc = QProcess() |
434 proc.start(Globals.getPythonExecutable(), args) |
435 proc.start(PythonUtilities.getPythonExecutable(), args) |
435 procStarted = proc.waitForStarted(10000) |
436 procStarted = proc.waitForStarted(10000) |
436 if procStarted: |
437 if procStarted: |
437 proc.waitForFinished(10000) |
438 proc.waitForFinished(10000) |
438 |
439 |
439 @pyqtSlot() |
440 @pyqtSlot() |
440 def __installEspTool(self): |
441 def __installEspTool(self): |
441 """ |
442 """ |
442 Private slot to install the esptool package via pip. |
443 Private slot to install the esptool package via pip. |
443 """ |
444 """ |
444 pip = ericApp().getObject("Pip") |
445 pip = ericApp().getObject("Pip") |
445 pip.installPackages(["esptool"], interpreter=Globals.getPythonExecutable()) |
446 pip.installPackages( |
|
447 ["esptool"], interpreter=PythonUtilities.getPythonExecutable() |
|
448 ) |
446 |
449 |
447 def getDocumentationUrl(self): |
450 def getDocumentationUrl(self): |
448 """ |
451 """ |
449 Public method to get the device documentation URL. |
452 Public method to get the device documentation URL. |
450 |
453 |