cope with unknown disk serial/model/etc much better
This commit is contained in:
parent
f28df37113
commit
703a9003f4
|
@ -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
|
||||
|
|
|
@ -100,6 +100,7 @@ def asdict(inst):
|
|||
if v:
|
||||
if hasattr(v, 'id'):
|
||||
v = v.id
|
||||
if v is not None:
|
||||
r[field.name] = v
|
||||
return r
|
||||
|
||||
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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([
|
||||
|
|
Loading…
Reference in New Issue