src/eric7/MicroPython/UF2FlashDialog.py

branch
eric7
changeset 10370
d84b074f772c
parent 10253
f9a0704d16b2
child 10373
093dcebe5ecb
equal deleted inserted replaced
10369:170795bb532d 10370:d84b074f772c
672 672
673 # step 1: determine all known UF2 volumes that are mounted 673 # step 1: determine all known UF2 volumes that are mounted
674 if not OSUtilities.isWindowsPlatform(): 674 if not OSUtilities.isWindowsPlatform():
675 userMounts = FileSystemUtilities.getUserMounts() 675 userMounts = FileSystemUtilities.getUserMounts()
676 676
677 boardTypes = [boardType] if boardType else list(SupportedUF2Boards.keys()) 677 boardTypes = [boardType] if boardType else [*SupportedUF2Boards.keys()]
678 for board in boardTypes: 678 for board in boardTypes:
679 for vidpid, volumes in SupportedUF2Boards[board]["volumes"].items(): 679 for vidpid, volumes in SupportedUF2Boards[board]["volumes"].items():
680 for volume, description in volumes: 680 for volume, description in volumes:
681 if OSUtilities.isWindowsPlatform(): 681 if OSUtilities.isWindowsPlatform():
682 if FileSystemUtilities.findVolume(volume, findAll=True): 682 if FileSystemUtilities.findVolume(volume, findAll=True):
713 port.description(), 713 port.description(),
714 (vid, pid), 714 (vid, pid),
715 ) 715 )
716 ) 716 )
717 717
718 return list(foundDevices) 718 return [*foundDevices]
719 719
720 720
721 class UF2FlashDialog(QDialog, Ui_UF2FlashDialog): 721 class UF2FlashDialog(QDialog, Ui_UF2FlashDialog):
722 """ 722 """
723 Class implementing a dialog to flash any UF2 capable device. 723 Class implementing a dialog to flash any UF2 capable device.
778 self.infoEdit.clear() 778 self.infoEdit.clear()
779 779
780 # now populate the entries with data 780 # now populate the entries with data
781 devices = getFoundDevices(boardType=self.__boardType) 781 devices = getFoundDevices(boardType=self.__boardType)
782 if len(devices) == 0: 782 if len(devices) == 0:
783 # no device detected 783 # no device set yet
784 devices = list( 784 devices = [
785 filter( 785 d
786 lambda x: x[0] in SupportedUF2Boards, 786 for d in Devices.getFoundDevices()[0]
787 Devices.getFoundDevices()[0], 787 if d[0] in SupportedUF2Boards
788 ) 788 ]
789 self.devicesComboBox.addItem("")
790 self.devicesComboBox.addItem(self.tr("Manual Select"))
791 self.devicesComboBox.setItemData(
792 self.devicesComboBox.count() - 1, self.__manualType, self.DeviceTypeRole
789 ) 793 )
794 self.on_devicesComboBox_currentIndexChanged(0)
790 if devices: 795 if devices:
791 self.__showSpecificInstructions(list(devices)) 796 self.__showSpecificInstructions(devices)
792 else: 797 else:
793 self.__showAllInstructions() 798 self.__showAllInstructions()
794 self.devicesComboBox.addItem(self.tr("Manual Select"))
795 self.devicesComboBox.setItemData(0, self.__manualType, self.DeviceTypeRole)
796 elif len(devices) == 1: 799 elif len(devices) == 1:
797 # set the board type to the found one 800 # set the board type to the found one
798 self.__boardType = devices[0][0] 801 self.__boardType = devices[0][0]
799 802
800 self.devicesComboBox.addItem(devices[0][1]) 803 self.devicesComboBox.addItem(devices[0][1])
1130 self, 1133 self,
1131 self.tr("Flash UF2 Device"), 1134 self.tr("Flash UF2 Device"),
1132 self.tr("""No UF2 device 'boot' volumes found."""), 1135 self.tr("""No UF2 device 'boot' volumes found."""),
1133 ) 1136 )
1134 elif len(foundBootVolumes) == 1: 1137 elif len(foundBootVolumes) == 1:
1135 selectedVolume = list(foundBootVolumes)[0] 1138 selectedVolume = [*foundBootVolumes][0]
1136 else: 1139 else:
1137 result, ok = QInputDialog.getItem( 1140 result, ok = QInputDialog.getItem(
1138 self, 1141 self,
1139 QCoreApplication.translate("UF2FlashDialog", "Flash UF2 Device"), 1142 QCoreApplication.translate("UF2FlashDialog", "Flash UF2 Device"),
1140 QCoreApplication.translate( 1143 QCoreApplication.translate(
1141 "UF2FlashDialog", "Select the Boot Volume of the device:" 1144 "UF2FlashDialog", "Select the Boot Volume of the device:"
1142 ), 1145 ),
1143 list(foundBootVolumes), 1146 [*foundBootVolumes],
1144 0, 1147 0,
1145 True, 1148 True,
1146 ) 1149 )
1147 selectedVolume = result if ok else "" 1150 selectedVolume = result if ok else ""
1148 1151

eric ide

mercurial