diff --git a/subiquity/controllers/filesystem.py b/subiquity/controllers/filesystem.py index 2bd696ef..a6f432ec 100644 --- a/subiquity/controllers/filesystem.py +++ b/subiquity/controllers/filesystem.py @@ -110,8 +110,8 @@ class FilesystemController(BaseController): # Filesystem/Disk partition ----------------------------------------------- def partition_disk(self, disk): - log.debug("In disk partition view, using {} as the disk.".format(disk.serial)) - title = (_("Partition, format, and mount {}").format(disk.serial)) + log.debug("In disk partition view, using {} as the disk.".format(disk.label)) + title = (_("Partition, format, and mount {}").format(disk.label)) footer = (_("Partition the disk, or format the entire device " "without partitions")) self.ui.set_header(title) @@ -276,8 +276,8 @@ class FilesystemController(BaseController): self.signal.prev_signal() def format_entire(self, disk): - log.debug("format_entire {}".format(disk.serial)) - header = (_("Format and/or mount {}").format(disk.serial)) + log.debug("format_entire {}".format(disk.label)) + header = (_("Format and/or mount {}").format(disk.label)) footer = _("Format or mount whole disk.") self.ui.set_header(header) self.ui.set_footer(footer) @@ -287,10 +287,10 @@ class FilesystemController(BaseController): def format_mount_partition(self, partition): log.debug("format_entire {}".format(partition)) if partition.fs() is not None: - header = (_("Mount partition {} of {}").format(partition.number, partition.device.serial)) + header = (_("Mount partition {} of {}").format(partition.number, partition.device.label)) footer = _("Mount partition.") else: - header = (_("Format and mount partition {} of {}").format(partition.number, partition.device.serial)) + header = (_("Format and mount partition {} of {}").format(partition.number, partition.device.label)) footer = _("Format and mount partition.") self.ui.set_header(header) self.ui.set_footer(footer) @@ -342,6 +342,12 @@ class FilesystemController(BaseController): 'vendor': disk._info.vendor, 'rotational': 'true' if rotational == '1' else 'false', } + if dinfo['serial'] is None: + dinfo['serial'] = 'unknown' + if dinfo['model'] is None: + dinfo['model'] = 'unknown' + if dinfo['vendor'] is None: + dinfo['vendor'] = 'unknown' template = """\n {devname}:\n diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py index 363d6e56..90b1ba7a 100644 --- a/subiquity/models/filesystem.py +++ b/subiquity/models/filesystem.py @@ -100,7 +100,8 @@ def asdict(inst): if v: if hasattr(v, 'id'): v = v.id - r[field.name] = v + if v is not None: + r[field.name] = v return r # This code is not going to make much sense unless you have read @@ -170,6 +171,12 @@ class Disk: def desc(self): return "local disk" + @property + def label(self): + if self.serial is not None: + return self.serial + return self.path + @property def used(self): if self._fs is not None: @@ -336,7 +343,7 @@ class FilesystemModel(object): self._disks[disk.path] = disk def all_disks(self): - return sorted(self._available_disks.values(), key=lambda x:x.serial) + return sorted(self._available_disks.values(), key=lambda x:x.label) def get_disk(self, path): return self._available_disks.get(path) diff --git a/subiquity/ui/views/filesystem/filesystem.py b/subiquity/ui/views/filesystem/filesystem.py index 06219409..d59f5bc5 100644 --- a/subiquity/ui/views/filesystem/filesystem.py +++ b/subiquity/ui/views/filesystem/filesystem.py @@ -171,7 +171,7 @@ class FilesystemView(BaseView): col3(Text("DEVICE"), Text("SIZE", align="center"), Text("TYPE")) for disk in self.model.all_disks(): - disk_label = Text(disk.serial) + disk_label = Text(disk.label) size = Text(humanize_size(disk.size).rjust(9)) typ = Text(disk.desc()) col3(disk_label, size, typ) diff --git a/subiquity/ui/views/filesystem/guided.py b/subiquity/ui/views/filesystem/guided.py index ffc8a026..2a23d467 100644 --- a/subiquity/ui/views/filesystem/guided.py +++ b/subiquity/ui/views/filesystem/guided.py @@ -69,7 +69,7 @@ class GuidedDiskSelectionView(BaseView): disks = [] for disk in self.model.all_disks(): disk_btn = forward_btn( - "%-40s %s"%(disk.serial, humanize_size(disk.size).rjust(9)), + "%-40s %s"%(disk.label, humanize_size(disk.size).rjust(9)), on_press=self.choose_disk, user_arg=disk) disks.append(disk_btn) lb = ListBox([