5 |
5 |
6 """ |
6 """ |
7 Module implementing a dialog to flash any UF2 capable device. |
7 Module implementing a dialog to flash any UF2 capable device. |
8 """ |
8 """ |
9 |
9 |
|
10 import contextlib |
10 import os |
11 import os |
11 import shutil |
12 import shutil |
12 |
13 |
13 from PyQt6.QtCore import QCoreApplication, QEventLoop, Qt, QThread, pyqtSlot |
14 from PyQt6.QtCore import QCoreApplication, QEventLoop, Qt, QThread, pyqtSlot |
14 from PyQt6.QtSerialPort import QSerialPortInfo |
15 from PyQt6.QtSerialPort import QSerialPortInfo |
1019 ).format(firmwareType) |
1020 ).format(firmwareType) |
1020 ) |
1021 ) |
1021 QCoreApplication.processEvents( |
1022 QCoreApplication.processEvents( |
1022 QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents |
1023 QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents |
1023 ) |
1024 ) |
1024 shutil.copy(firmwarePath, volumePath) |
1025 with contextlib.suppress(FileNotFoundError): |
|
1026 shutil.copy(firmwarePath, volumePath) |
1025 QThread.sleep(1) |
1027 QThread.sleep(1) |
1026 self.on_refreshButton_clicked() |
1028 self.on_refreshButton_clicked() |
1027 |
1029 |
1028 @pyqtSlot() |
1030 @pyqtSlot() |
1029 def on_refreshButton_clicked(self): |
1031 def on_refreshButton_clicked(self): |