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 -----------------------------------------------
|
# Filesystem/Disk partition -----------------------------------------------
|
||||||
def partition_disk(self, disk):
|
def partition_disk(self, disk):
|
||||||
log.debug("In disk partition view, using {} as the disk.".format(disk.serial))
|
log.debug("In disk partition view, using {} as the disk.".format(disk.label))
|
||||||
title = (_("Partition, format, and mount {}").format(disk.serial))
|
title = (_("Partition, format, and mount {}").format(disk.label))
|
||||||
footer = (_("Partition the disk, or format the entire device "
|
footer = (_("Partition the disk, or format the entire device "
|
||||||
"without partitions"))
|
"without partitions"))
|
||||||
self.ui.set_header(title)
|
self.ui.set_header(title)
|
||||||
|
@ -276,8 +276,8 @@ class FilesystemController(BaseController):
|
||||||
self.signal.prev_signal()
|
self.signal.prev_signal()
|
||||||
|
|
||||||
def format_entire(self, disk):
|
def format_entire(self, disk):
|
||||||
log.debug("format_entire {}".format(disk.serial))
|
log.debug("format_entire {}".format(disk.label))
|
||||||
header = (_("Format and/or mount {}").format(disk.serial))
|
header = (_("Format and/or mount {}").format(disk.label))
|
||||||
footer = _("Format or mount whole disk.")
|
footer = _("Format or mount whole disk.")
|
||||||
self.ui.set_header(header)
|
self.ui.set_header(header)
|
||||||
self.ui.set_footer(footer)
|
self.ui.set_footer(footer)
|
||||||
|
@ -287,10 +287,10 @@ class FilesystemController(BaseController):
|
||||||
def format_mount_partition(self, partition):
|
def format_mount_partition(self, partition):
|
||||||
log.debug("format_entire {}".format(partition))
|
log.debug("format_entire {}".format(partition))
|
||||||
if partition.fs() is not None:
|
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.")
|
footer = _("Mount partition.")
|
||||||
else:
|
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.")
|
footer = _("Format and mount partition.")
|
||||||
self.ui.set_header(header)
|
self.ui.set_header(header)
|
||||||
self.ui.set_footer(footer)
|
self.ui.set_footer(footer)
|
||||||
|
@ -342,6 +342,12 @@ class FilesystemController(BaseController):
|
||||||
'vendor': disk._info.vendor,
|
'vendor': disk._info.vendor,
|
||||||
'rotational': 'true' if rotational == '1' else 'false',
|
'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
|
template = """\n
|
||||||
{devname}:\n
|
{devname}:\n
|
||||||
|
|
|
@ -100,7 +100,8 @@ def asdict(inst):
|
||||||
if v:
|
if v:
|
||||||
if hasattr(v, 'id'):
|
if hasattr(v, 'id'):
|
||||||
v = v.id
|
v = v.id
|
||||||
r[field.name] = v
|
if v is not None:
|
||||||
|
r[field.name] = v
|
||||||
return r
|
return r
|
||||||
|
|
||||||
# This code is not going to make much sense unless you have read
|
# This code is not going to make much sense unless you have read
|
||||||
|
@ -170,6 +171,12 @@ class Disk:
|
||||||
def desc(self):
|
def desc(self):
|
||||||
return "local disk"
|
return "local disk"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def label(self):
|
||||||
|
if self.serial is not None:
|
||||||
|
return self.serial
|
||||||
|
return self.path
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def used(self):
|
def used(self):
|
||||||
if self._fs is not None:
|
if self._fs is not None:
|
||||||
|
@ -336,7 +343,7 @@ class FilesystemModel(object):
|
||||||
self._disks[disk.path] = disk
|
self._disks[disk.path] = disk
|
||||||
|
|
||||||
def all_disks(self):
|
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):
|
def get_disk(self, path):
|
||||||
return self._available_disks.get(path)
|
return self._available_disks.get(path)
|
||||||
|
|
|
@ -171,7 +171,7 @@ class FilesystemView(BaseView):
|
||||||
col3(Text("DEVICE"), Text("SIZE", align="center"), Text("TYPE"))
|
col3(Text("DEVICE"), Text("SIZE", align="center"), Text("TYPE"))
|
||||||
|
|
||||||
for disk in self.model.all_disks():
|
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))
|
size = Text(humanize_size(disk.size).rjust(9))
|
||||||
typ = Text(disk.desc())
|
typ = Text(disk.desc())
|
||||||
col3(disk_label, size, typ)
|
col3(disk_label, size, typ)
|
||||||
|
|
|
@ -69,7 +69,7 @@ class GuidedDiskSelectionView(BaseView):
|
||||||
disks = []
|
disks = []
|
||||||
for disk in self.model.all_disks():
|
for disk in self.model.all_disks():
|
||||||
disk_btn = forward_btn(
|
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)
|
on_press=self.choose_disk, user_arg=disk)
|
||||||
disks.append(disk_btn)
|
disks.append(disk_btn)
|
||||||
lb = ListBox([
|
lb = ListBox([
|
||||||
|
|
Loading…
Reference in New Issue