diff options
author | Papoteur <papoteur@mageia.org> | 2021-01-01 16:23:07 +0100 |
---|---|---|
committer | Papoteur <papoteur@mageia.org> | 2021-01-01 16:23:07 +0100 |
commit | ececde71973467c60b34677b60824f0c6e1f30bb (patch) | |
tree | a76def86c51f23bfbcab72cf7a337027ed5853c6 | |
parent | 480cf4c812d8b24839f7ac361b2c70433b9bd049 (diff) | |
download | isodumper-ececde71973467c60b34677b60824f0c6e1f30bb.tar isodumper-ececde71973467c60b34677b60824f0c6e1f30bb.tar.gz isodumper-ececde71973467c60b34677b60824f0c6e1f30bb.tar.bz2 isodumper-ececde71973467c60b34677b60824f0c6e1f30bb.tar.xz isodumper-ececde71973467c60b34677b60824f0c6e1f30bb.zip |
Add logic for partition operations
-rwxr-xr-x | lib/isodumper.py | 87 |
1 files changed, 56 insertions, 31 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py index d3c6076..e22d793 100755 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -182,7 +182,6 @@ class IsoDumper(basedialog.BaseDialog): return True def active_signal(self): - print("Active") self.u.iface["org.freedesktop.DBus.ObjectManager"].InterfacesAdded.connect(self.refresh_signal) self.u.iface["org.freedesktop.DBus.ObjectManager"].InterfacesRemoved.connect(self.refresh_signal) @@ -260,11 +259,20 @@ class IsoDumper(basedialog.BaseDialog): self.start_bt.setEnabled() def do_format(self): - code, format_type, name = self.ask_format() - if code: + #code, format_type, name = self.ask_format() + if self.partition_cb.value() != "": + format_type = list(self.format_type.keys())[list(self.format_type.values()).index(self.partition_cb.value())] + if format_type == 'persist': + self.emergency(_("Persistence partition is to use when writing a Live ISO image.")) + return target = self.dev.split('(')[1].split(')')[0] - info = Info(_("Formatting confirmation"), True, self.warning) - if self.ask_YesOrNo(info): + info = Info(_("Formatting confirmation in {}".format(self.partition_cb.value())), True, self.warning) + if self.ask_YesOrNo(info): + name = self.partition_label.value() + if format_type == 'fat32': + name = name.upper()[:11] + elif format_type == 'exfat' or format_type == 'ntfs': + name = name[:32] rc = self.raw_format(target, format_type, name) self.operation = False if rc == 0: @@ -299,8 +307,6 @@ class IsoDumper(basedialog.BaseDialog): #self.persistencecb.setDisabled() self.partition_cb.setDisabled() self.partition_label.setDisabled() - self.revealcb.setChecked(False) - self.revealcb.setDisabled() self.cryptcb.setChecked(False) self.cryptcb.setDisabled() self.cryptkey.setDisabled() @@ -385,8 +391,6 @@ class IsoDumper(basedialog.BaseDialog): self.wip_unsensitive() self.writebt.setDisabled() self.devicelist.setDisabled() - self.formatbt.setDisabled() - self.backupbt.setDisabled() self.backup_select.setDisabled() self.progress.setEnabled() source = self.img_name @@ -550,7 +554,7 @@ class IsoDumper(basedialog.BaseDialog): def final_unsensitive(self): self.ima.setDisabled() self.devicelist.setDisabled() - self.writebt.setDisabled() + #self.writebt.setDisabled() self.progress.setDisabled() self.backup_select.setDisabled() #self.persistencecb.setDisabled() @@ -558,9 +562,9 @@ class IsoDumper(basedialog.BaseDialog): def wip_unsensitive(self): self.ima.setDisabled() self.devicelist.setDisabled() - self.writebt.setDisabled() + #self.writebt.setDisabled() self.backup_select.setDisabled() - self.backupbt.setDisabled() + #self.backupbt.setDisabled() self.refreshbt.setDisabled() #elf.persistencecb.setDisabled() @@ -709,27 +713,31 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog self.partition_cbox = self.factory.createCheckBox(self.partitionbox, _("Create partition of type:")) self.partition_cbox.setNotify() self.partition_cb = self.factory.createComboBox(self.partitionbox, _("Type:")) - self.partition_cb.addItem(_("FAT 32"), False) - self.partition_cb.addItem(_("ext4"), False) - self.partition_cb.addItem(_("NTFS"), False) - self.partition_cb.addItem(_("exFAT"), False) - self.partition_cb.addItem(_("Persistent partition"), False) + self.partition_cb.addItem("", True) + self.format_type = {'fat32': _("FAT 32"), + 'ext4': _("ext4"), + 'ntfs': _("NTFS"), + 'exfat': _("exfat"), + 'persist': _("Persistent partition"), + } + for key in self.format_type: + self.partition_cb.addItem(self.format_type[key], False) + self.partition_cb.setNotify() self.partition_label = self.factory.createInputField(self.partitionbox, _("Label:")) self.partition_label.setStretchable(0, True) self.persistencebox = self.factory.createHBox(self.operationbox) #self.persistencecb = self.factory.createCheckBox(self.persistencecol1, # _("Add a persistent partition in the remaining space")) - self.cryptcb = self.factory.createCheckBox(self.persistencebox, _("Encrypt partition using LUKS, with key:")) + self.cryptcb = self.factory.createCheckBox(self.persistencebox, _("Encrypt partition using LUKS, with key:")) + self.cryptcb.setNotify() self.cryptkey = self.factory.createInputField(self.persistencebox, _("Key:"), passwordMode=True) self.cryptkey.setStretchable(0, True) - self.revealcb = self.factory.createCheckBox(self.persistencebox, _("Reveal key")) - self.revealcb.setNotify() - self.cryptcb.setNotify() #self.formatbt = self.factory.createPushButton(self.formatbox, _("Format the device")) self.execute_frame = self.factory.createFrame(self.box, _("Execution")) self.execute_framevb = self.factory.createVBox(self.execute_frame) self.execute_label = self.factory.createLabel(self.execute_framevb, _("When you are sure all options are correct, start:")) self.start_bt = self.factory.createPushButton(self.execute_framevb, _("Execute")) + self.start_bt.setNotify() self.progressbox = self.factory.createHBox(self.execute_framevb) self.progress = self.factory.createProgressBar(self.progressbox, _("Progress"), 100) self.progress.setStretchable(0, True) @@ -749,7 +757,6 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog # Connect events self.eventManager.addWidgetEvent(self.quitbt, self.confirm_close) self.eventManager.addWidgetEvent(self.ima, self.ask_image) - #self.eventManager.addWidgetEvent(self.persistencecb, self.check_persistence) #self.eventManager.addWidgetEvent(self.writebt, self.do_write) self.eventManager.addWidgetEvent(self.cryptcb, self.check_encryt) #self.eventManager.addWidgetEvent(self.backupbt, self.backup_go) @@ -758,7 +765,9 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog self.eventManager.addWidgetEvent(self.backup_cbox, self.select_backup) self.eventManager.addWidgetEvent(self.write_cbox, self.select_write) self.eventManager.addWidgetEvent(self.partition_cbox, self.select_partition) + self.eventManager.addWidgetEvent(self.partition_cb, self.select_partition_type) self.eventManager.addWidgetEvent(self.devicelist, self.device_selected) + self.eventManager.addWidgetEvent(self.start_bt, self.start) self.eventManager.addWidgetEvent(self.refreshbt, self.update_list) self.eventManager.addWidgetEvent(self.helpbt, self.help_dialog) self.eventManager.addWidgetEvent(self.aboutbt, self.aboutDialog) @@ -822,14 +831,15 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog self.partition_cb.setDisabled() self.partition_label.setDisabled() - def check_persistence(self): - pass - #if self.persistencecb.isChecked(): - #self.cryptcb.setEnabled() - #else: - #self.cryptcb.setDisabled() - #self.cryptkey.setDisabled() - #self.cryptcb.setChecked(False) + def select_partition_type(self): + if self.partition_cb.value() in ("ext4" ,"Persistent partition"): + self.cryptcb.setEnabled() + if self.partition_cb.value() != "": + self.start_bt.setEnabled() + else: + self.cryptcb.setDisabled() + self.cryptkey.setDisabled() + self.start_bt.setDisabled() def check_encryt(self): if self.cryptcb.isChecked(): @@ -837,6 +847,21 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog else: self.cryptkey.setDisabled() + def start(self): + if self.backup_cbox.isChecked(): + # check that a name is set + pass + if self.write_cbox.isChecked(): + if self.image_is_selected: + self.do_write() + else: + self.emergency(_("No image is selected.")) + return + if self.partition_cbox.isChecked(): + # Create a partition without writing image, will use all the device space. + self.do_format() + + def ask_format(self): atelier = yui.YUI.widgetFactory() dialog = atelier.createPopupDialog() @@ -944,7 +969,7 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog def run(self, debug=False): self._setupUI() - + # setting to False will break the event loop self._running = True self.timeout = 100 |