def _run_dialogs(self, disks, start_with): rc = self.run_lightbox_dialog(start_with) if rc == RESPONSE_RECLAIM: # we need to run another dialog # respect disk selection and other choices in the ReclaimDialog self.apply() resize_dialog = ResizeDialog(self.data, self.storage, self.payload) resize_dialog.refresh(disks) return self._run_dialogs(disks, start_with=resize_dialog) else: # we are done return rc
def _skip_to_automatic_partitioning(self): """Skip to the automatic partitioning. The user has requested to create the partitioning automatically. Ask for missing information and set up the automatic partitioning, so it can be later applied in the execute method. """ # Set up the encryption. self._partitioning_request.encrypted = self._encrypted_checkbox.get_active( ) # Ask for a passphrase. if self._partitioning_request.encrypted: dialog = PassphraseDialog(self.data, self._partitioning_request.passphrase) rc = self.run_lightbox_dialog(dialog) if rc != 1: self._back_clicked = False return self._partitioning_request.passphrase = dialog.passphrase # Set up the disk selection and initialization. self.apply() # Use the automatic partitioning and reset it. self._partitioning = create_partitioning(PARTITIONING_METHOD_AUTOMATIC) self._partitioning.Request = \ PartitioningRequest.to_structure(self._partitioning_request) # Reclaim space. disks = filter_disks_by_names(self._available_disks, self._selected_disks) rc = self._check_space_and_run_dialog(self._partitioning, disks) if rc == RESPONSE_RECLAIM: dialog = ResizeDialog(self.data, self.payload, self._partitioning, disks) dialog.refresh() rc = self.run_lightbox_dialog(dialog) # Plan the next action. if rc == RESPONSE_OK: # nothing special needed self._skip_to_spoke(None) return if rc == RESPONSE_CANCEL: # A cancel button was clicked on one of the dialogs. Stay on this # spoke. Generally, this is because the user wants to add more disks. self._back_clicked = False return if rc == RESPONSE_MODIFY_SW: # The "Fedora software selection" link was clicked on one of the # dialogs. Send the user to the software spoke. self._skip_to_spoke("SoftwareSelectionSpoke") return if rc == RESPONSE_QUIT: # Not enough space, and the user can't do anything about it so # they chose to quit. raise SystemExit("user-selected exit") # I don't know how we'd get here, but might as well have a # catch-all. Just stay on this spoke. self._back_clicked = False return
def on_back_clicked(self, button): # We can't exit early if it looks like nothing has changed because the # user might want to change settings presented in the dialogs shown from # within this method. # Do not enter this method multiple times if user clicking multiple times # on back button if self._back_clicked: return else: self._back_clicked = True # make sure the snapshot of unmodified on-disk-storage model is created if not on_disk_storage.created: on_disk_storage.create_snapshot(self.storage) if self.autopart_missing_passphrase: self._setup_passphrase() NormalSpoke.on_back_clicked(self, button) return # No disks selected? The user wants to back out of the storage spoke. if not self.selected_disks: NormalSpoke.on_back_clicked(self, button) return disk_selection_changed = False if self._last_selected_disks: disk_selection_changed = (self._last_selected_disks != set(self.selected_disks)) # remember the disk selection for future decisions self._last_selected_disks = set(self.selected_disks) if disk_selection_changed: # Changing disk selection is really, really complicated and has # always been causing numerous hard bugs. Let's not play the hero # game and just revert everything and start over again. on_disk_storage.reset_to_snapshot(self.storage) self.disks = getDisks(self.storage.devicetree) else: # Remove all non-existing devices if autopart was active when we last # refreshed. if self._previous_autopart: self._previous_autopart = False self._remove_nonexistant_partitions() # hide disks as requested self._hide_disks() # make sure no containers were split up by the user's disk selection self.clear_info() # if there are some disk selection errors we don't let user to leave the # spoke, so these errors don't have to go to self.errors self.disks_errors = checkDiskSelection(self.storage, self.selected_disks) if self.disks_errors: # The disk selection has to make sense before we can proceed. self.set_error(_("There was a problem with your disk selection. " "Click here for details.")) self._back_clicked = False return if arch.isS390(): # check for unformatted DASDs and launch dasdfmt if any discovered rc = self._check_dasd_formats() if rc == DASD_FORMAT_NO_CHANGE: pass elif rc == DASD_FORMAT_REFRESH: # User hit OK on the dialog self.refresh() elif rc == DASD_FORMAT_RETURN_TO_HUB: # User clicked uri to return to hub. NormalSpoke.on_back_clicked(self, button) return else: # User either hit cancel on the dialog or closed it via escape, # there was no formatting done. self._back_clicked = False return # even if they're not doing autopart, setting autopart.encrypted # establishes a default of encrypting new devices self.encrypted = self._encrypted.get_active() # We might first need to ask about an encryption passphrase. if self.encrypted and not self._setup_passphrase(): self._back_clicked = False return # At this point there are three possible states: # 1) user chose custom part => just send them to the CustomPart spoke # 2) user wants to reclaim some more space => run the ResizeDialog # 3) we are just asked to do autopart => check free space and see if we need # user to do anything more self.autopart = not self._customPart.get_active() disks = [d for d in self.disks if d.name in self.selected_disks] dialog = None if not self.autopart: self.skipTo = "CustomPartitioningSpoke" elif self._reclaim.get_active(): # HINT: change the logic of this 'if' statement if we are asked to # support "reclaim before custom partitioning" # respect disk selection and other choices in the ReclaimDialog self.apply() dialog = ResizeDialog(self.data, self.storage, self.payload) dialog.refresh(disks) else: dialog = self._check_space_and_get_dialog(disks) if dialog: # more dialogs may need to be run based on user choices, but we are # only interested in the final result rc = self._run_dialogs(disks, start_with=dialog) if rc == RESPONSE_OK: # nothing special needed pass elif rc == RESPONSE_CANCEL: # A cancel button was clicked on one of the dialogs. Stay on this # spoke. Generally, this is because the user wants to add more disks. self._back_clicked = False return elif rc == RESPONSE_MODIFY_SW: # The "Fedora software selection" link was clicked on one of the # dialogs. Send the user to the software spoke. self.skipTo = "SoftwareSelectionSpoke" elif rc == RESPONSE_QUIT: # Not enough space, and the user can't do anything about it so # they chose to quit. raise SystemExit("user-selected exit") else: # I don't know how we'd get here, but might as well have a # catch-all. Just stay on this spoke. self._back_clicked = False return if self.autopart: refreshAutoSwapSize(self.storage) self.applyOnSkip = True NormalSpoke.on_back_clicked(self, button)
def _show_resize_dialog(self, disks): resizeDialog = ResizeDialog(self.data, self.storage, self.payload) resizeDialog.refresh(disks) rc = self.run_lightbox_dialog(resizeDialog) return rc
def on_back_clicked(self, button): # We can't exit early if it looks like nothing has changed because the # user might want to change settings presented in the dialogs shown from # within this method. # Do not enter this method multiple times if user clicking multiple times # on back button if self._back_clicked: return else: self._back_clicked = True # make sure the snapshot of unmodified on-disk-storage model is created if not on_disk_storage.created: on_disk_storage.create_snapshot(self.storage) if self.autopart_missing_passphrase: self._setup_passphrase() NormalSpoke.on_back_clicked(self, button) return # No disks selected? The user wants to back out of the storage spoke. if not self.selected_disks: NormalSpoke.on_back_clicked(self, button) return disk_selection_changed = False if self._last_selected_disks: disk_selection_changed = (self._last_selected_disks != set( self.selected_disks)) # remember the disk selection for future decisions self._last_selected_disks = set(self.selected_disks) if disk_selection_changed: # Changing disk selection is really, really complicated and has # always been causing numerous hard bugs. Let's not play the hero # game and just revert everything and start over again. on_disk_storage.reset_to_snapshot(self.storage) self.disks = getDisks(self.storage.devicetree) else: # Remove all non-existing devices if autopart was active when we last # refreshed. if self._previous_autopart: self._previous_autopart = False self._remove_nonexistant_partitions() # hide disks as requested self._hide_disks() # make sure no containers were split up by the user's disk selection self.clear_info() # if there are some disk selection errors we don't let user to leave the # spoke, so these errors don't have to go to self.errors self.disks_errors = checkDiskSelection(self.storage, self.selected_disks) if self.disks_errors: # The disk selection has to make sense before we can proceed. self.set_error( _("There was a problem with your disk selection. " "Click here for details.")) self._back_clicked = False return if arch.isS390(): # check for unformatted DASDs and launch dasdfmt if any discovered rc = self._check_dasd_formats() if rc == DASD_FORMAT_NO_CHANGE: pass elif rc == DASD_FORMAT_REFRESH: # User hit OK on the dialog self.refresh() elif rc == DASD_FORMAT_RETURN_TO_HUB: # User clicked uri to return to hub. NormalSpoke.on_back_clicked(self, button) return else: # User either hit cancel on the dialog or closed it via escape, # there was no formatting done. self._back_clicked = False return # even if they're not doing autopart, setting autopart.encrypted # establishes a default of encrypting new devices self.encrypted = self._encrypted.get_active() # We might first need to ask about an encryption passphrase. if self.encrypted and not self._setup_passphrase(): self._back_clicked = False return # At this point there are three possible states: # 1) user chose custom part => just send them to the CustomPart spoke # 2) user wants to reclaim some more space => run the ResizeDialog # 3) we are just asked to do autopart => check free space and see if we need # user to do anything more self.autopart = not self._customPart.get_active() disks = [d for d in self.disks if d.name in self.selected_disks] dialog = None if not self.autopart: self.skipTo = "CustomPartitioningSpoke" elif self._reclaim.get_active(): # HINT: change the logic of this 'if' statement if we are asked to # support "reclaim before custom partitioning" # respect disk selection and other choices in the ReclaimDialog self.apply() dialog = ResizeDialog(self.data, self.storage, self.payload) dialog.refresh(disks) else: dialog = self._check_space_and_get_dialog(disks) if dialog: # more dialogs may need to be run based on user choices, but we are # only interested in the final result rc = self._run_dialogs(disks, start_with=dialog) if rc == RESPONSE_OK: # nothing special needed pass elif rc == RESPONSE_CANCEL: # A cancel button was clicked on one of the dialogs. Stay on this # spoke. Generally, this is because the user wants to add more disks. self._back_clicked = False return elif rc == RESPONSE_MODIFY_SW: # The "Fedora software selection" link was clicked on one of the # dialogs. Send the user to the software spoke. self.skipTo = "SoftwareSelectionSpoke" elif rc == RESPONSE_QUIT: # Not enough space, and the user can't do anything about it so # they chose to quit. raise SystemExit("user-selected exit") else: # I don't know how we'd get here, but might as well have a # catch-all. Just stay on this spoke. self._back_clicked = False return if self.autopart: refreshAutoSwapSize(self.storage) self.applyOnSkip = True NormalSpoke.on_back_clicked(self, button)