def populate_partition_selection_table(self, drive_key): print('Received drive key ' + drive_key) print('drive state is ' + str(self.drive_state)) self.save_partition_list_store.clear() try: if 'partitions' in self.drive_state[drive_key].keys(): for partition_key in self.drive_state[drive_key][ 'partitions'].keys(): flattened_partition_description = CombinedDriveState.flatten_partition_description( self.drive_state, drive_key, partition_key) # Add row that's ticked self.save_partition_list_store.append( [partition_key, True, flattened_partition_description]) else: # Add the drive itself flattened_partition_description = CombinedDriveState.flatten_partition_description( self.drive_state, drive_key, drive_key) # Add row that's ticked self.save_partition_list_store.append( [drive_key, True, flattened_partition_description]) except Exception as exception: tb = traceback.format_exc() traceback.print_exc() ErrorMessageModalPopup.display_nonfatal_warning_message( self.builder, tb) return
def populate_mount_partition_table(self, ignore_drive_key=None): print('drive state is ' + str(self.drive_state)) self.mount_partition_list_store.clear() index = 0 for drive_key in self.drive_state.keys(): try: if drive_key == ignore_drive_key: continue if 'partitions' not in self.drive_state[drive_key].keys(): continue for partition_key in self.drive_state[drive_key]['partitions'].keys(): with self._is_displaying_advanced_information_lock: if self._is_displaying_advanced_information: # Display a advanced-user partition name eg, "nvme0n1p1". human_friendly_partition_name = partition_key else: if self.drive_state[drive_key]['type'] == 'loop': # Don't display certain non-block device if user has chosen to hide them. # TODO: Evaluate other partition types to be hidden. continue # Display a advanced-user partition name eg, "#4". human_friendly_partition_name = "#" + str(index + 1) flattened_partition_description = CombinedDriveState.flatten_partition_description(self.drive_state, drive_key, partition_key) if 'size' in self.drive_state[drive_key]['partitions'][partition_key].keys(): size_in_bytes = self.drive_state[drive_key]['partitions'][partition_key]['size'] enduser_readable_size = Utility.human_readable_filesize(int(size_in_bytes)) else: enduser_readable_size = "unknown_size" self.mount_partition_list_store.append([partition_key, human_friendly_partition_name, enduser_readable_size, flattened_partition_description]) index = index + 1 except Exception as exception: tb = traceback.format_exc() traceback.print_exc() ErrorMessageModalPopup.display_nonfatal_warning_message(self.builder, tb) return