eric7/MicroPython/PyBoardDevices.py

branch
eric7
changeset 8356
68ec9c3d4de5
parent 8322
b422b4e77d19
child 8358
144a6b854f70
equal deleted inserted replaced
8355:8a7677a63c8d 8356:68ec9c3d4de5
9 9
10 import os 10 import os
11 11
12 from PyQt6.QtCore import pyqtSlot, QStandardPaths 12 from PyQt6.QtCore import pyqtSlot, QStandardPaths
13 13
14 from E5Gui import E5MessageBox, E5FileDialog 14 from E5Gui import EricMessageBox, EricFileDialog
15 from E5Gui.E5Application import e5App 15 from E5Gui.EricApplication import ericApp
16 from E5Gui.E5ProcessDialog import E5ProcessDialog 16 from E5Gui.EricProcessDialog import EricProcessDialog
17 17
18 from .MicroPythonDevices import MicroPythonDevice 18 from .MicroPythonDevices import MicroPythonDevice
19 from .MicroPythonWidget import HAS_QTCHART 19 from .MicroPythonWidget import HAS_QTCHART
20 20
21 import Utilities 21 import Utilities
186 return self.selectDeviceDirectory(deviceDirectories) 186 return self.selectDeviceDirectory(deviceDirectories)
187 else: 187 else:
188 # return the default workspace and give the user a warning (unless 188 # return the default workspace and give the user a warning (unless
189 # silent mode is selected) 189 # silent mode is selected)
190 if not silent: 190 if not silent:
191 E5MessageBox.warning( 191 EricMessageBox.warning(
192 self.microPython, 192 self.microPython,
193 self.tr("Workspace Directory"), 193 self.tr("Workspace Directory"),
194 self.tr("Python files for PyBoard can be edited in" 194 self.tr("Python files for PyBoard can be edited in"
195 " place, if the device volume is locally" 195 " place, if the device volume is locally"
196 " available. Such a volume was not found. In" 196 " available. Such a volume was not found. In"
253 def __showFlashInstructions(self): 253 def __showFlashInstructions(self):
254 """ 254 """
255 Private slot to open the URL containing instructions for installing 255 Private slot to open the URL containing instructions for installing
256 MicroPython on the pyboard. 256 MicroPython on the pyboard.
257 """ 257 """
258 e5App().getObject("UserInterface").launchHelpViewer( 258 ericApp().getObject("UserInterface").launchHelpViewer(
259 PyBoardDevice.FlashInstructionsURL) 259 PyBoardDevice.FlashInstructionsURL)
260 260
261 def __dfuUtilAvailable(self): 261 def __dfuUtilAvailable(self):
262 """ 262 """
263 Private method to check the availability of dfu-util. 263 Private method to check the availability of dfu-util.
274 else: 274 else:
275 if Utilities.isExecutable(program): 275 if Utilities.isExecutable(program):
276 available = True 276 available = True
277 277
278 if not available: 278 if not available:
279 E5MessageBox.critical( 279 EricMessageBox.critical(
280 self.microPython, 280 self.microPython,
281 self.tr("dfu-util not available"), 281 self.tr("dfu-util not available"),
282 self.tr("""The dfu-util firmware flashing tool""" 282 self.tr("""The dfu-util firmware flashing tool"""
283 """ <b>dfu-util</b> cannot be found or is not""" 283 """ <b>dfu-util</b> cannot be found or is not"""
284 """ executable. Ensure it is in the search path""" 284 """ executable. Ensure it is in the search path"""
314 ) 314 )
315 315
316 msg += self.tr( 316 msg += self.tr(
317 "<p>Press <b>OK</b> to continue...</p>" 317 "<p>Press <b>OK</b> to continue...</p>"
318 ) 318 )
319 res = E5MessageBox.information( 319 res = EricMessageBox.information(
320 self.microPython, 320 self.microPython,
321 self.tr("Enable DFU mode"), 321 self.tr("Enable DFU mode"),
322 msg, 322 msg,
323 E5MessageBox.Abort | E5MessageBox.Ok) 323 EricMessageBox.Abort | EricMessageBox.Ok)
324 324
325 return res == E5MessageBox.Ok 325 return res == EricMessageBox.Ok
326 326
327 def __showDfuDisableInstructions(self): 327 def __showDfuDisableInstructions(self):
328 """ 328 """
329 Private method to show some instructions to disable the DFU mode. 329 Private method to show some instructions to disable the DFU mode.
330 """ 330 """
334 "<p>2. Remove the DFU jumper</p>" 334 "<p>2. Remove the DFU jumper</p>"
335 "<p>3. Re-connect your board</p>" 335 "<p>3. Re-connect your board</p>"
336 "<hr />" 336 "<hr />"
337 "<p>Press <b>OK</b> to continue...</p>" 337 "<p>Press <b>OK</b> to continue...</p>"
338 ) 338 )
339 E5MessageBox.information( 339 EricMessageBox.information(
340 self.microPython, 340 self.microPython,
341 self.tr("Disable DFU mode"), 341 self.tr("Disable DFU mode"),
342 msg 342 msg
343 ) 343 )
344 344
355 program = "dfu-util" 355 program = "dfu-util"
356 356
357 args = [ 357 args = [
358 "--list", 358 "--list",
359 ] 359 ]
360 dlg = E5ProcessDialog( 360 dlg = EricProcessDialog(
361 self.tr("'dfu-util' Output"), 361 self.tr("'dfu-util' Output"),
362 self.tr("List DFU capable Devices") 362 self.tr("List DFU capable Devices")
363 ) 363 )
364 res = dlg.startProcess(program, args) 364 res = dlg.startProcess(program, args)
365 if res: 365 if res:
377 if not program: 377 if not program:
378 program = "dfu-util" 378 program = "dfu-util"
379 379
380 downloadsPath = QStandardPaths.standardLocations( 380 downloadsPath = QStandardPaths.standardLocations(
381 QStandardPaths.StandardLocation.DownloadLocation)[0] 381 QStandardPaths.StandardLocation.DownloadLocation)[0]
382 firmware = E5FileDialog.getOpenFileName( 382 firmware = EricFileDialog.getOpenFileName(
383 self.microPython, 383 self.microPython,
384 self.tr("Flash MicroPython Firmware"), 384 self.tr("Flash MicroPython Firmware"),
385 downloadsPath, 385 downloadsPath,
386 self.tr( 386 self.tr(
387 "MicroPython Firmware Files (*.dfu);;All Files (*)") 387 "MicroPython Firmware Files (*.dfu);;All Files (*)")
389 if firmware and os.path.exists(firmware): 389 if firmware and os.path.exists(firmware):
390 args = [ 390 args = [
391 "--alt", "0", 391 "--alt", "0",
392 "--download", firmware, 392 "--download", firmware,
393 ] 393 ]
394 dlg = E5ProcessDialog( 394 dlg = EricProcessDialog(
395 self.tr("'dfu-util' Output"), 395 self.tr("'dfu-util' Output"),
396 self.tr("Flash MicroPython Firmware") 396 self.tr("Flash MicroPython Firmware")
397 ) 397 )
398 res = dlg.startProcess(program, args) 398 res = dlg.startProcess(program, args)
399 if res: 399 if res:

eric ide

mercurial