From 4837d7a148979b6e8ecf6afaf3a2e51ea7d0fe00 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Thu, 25 Aug 2016 15:31:21 +0200 Subject: [PATCH] show complete device description in wizard --- lib/base_wizard.py | 8 ++++++-- lib/plugins.py | 9 +++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/base_wizard.py b/lib/base_wizard.py index dddb55452..00d644b0c 100644 --- a/lib/base_wizard.py +++ b/lib/base_wizard.py @@ -194,14 +194,18 @@ class BaseWizard(object): # select device self.devices = devices choices = [] - for name, device_info in devices: - choices.append( ((name, device_info), device_info.description + ' [%s]'%name) ) + for name, info in devices: + state = _("initialized") if info.initialized else _("wiped") + label = info.label or _("An unnamed %s")%name + descr = "%s [%s, %s]" % (label, name, state) + choices.append(((name, info), descr)) msg = _('Select a device') + ':' self.choice_dialog(title=title, message=msg, choices=choices, run_next=self.on_device) def on_device(self, name, device_info): self.plugin = self.plugins.get_plugin(name) self.plugin.setup_device(device_info, self) + print device_info f = lambda x: self.run('on_hardware_account_id', name, device_info, x) self.account_id_dialog(run_next=f) diff --git a/lib/plugins.py b/lib/plugins.py index 406c5df03..5b82a6ccc 100644 --- a/lib/plugins.py +++ b/lib/plugins.py @@ -261,7 +261,7 @@ class DeviceUnpairableError(Exception): pass Device = namedtuple("Device", "path interface_number id_ product_key") -DeviceInfo = namedtuple("DeviceInfo", "device description initialized") +DeviceInfo = namedtuple("DeviceInfo", "device label initialized") class DeviceMgr(ThreadJob, PrintError): '''Manages hardware clients. A client communicates over a hardware @@ -443,10 +443,7 @@ class DeviceMgr(ThreadJob, PrintError): client = self.create_client(device, handler, plugin) if not client: continue - state = _("initialized") if client.is_initialized() else _("wiped") - label = client.label() or _("An unnamed %s") % plugin.device - descr = "%s (%s)" % (label, state) - infos.append(DeviceInfo(device, descr, client.is_initialized())) + infos.append(DeviceInfo(device, client.label(), client.is_initialized())) return infos @@ -467,7 +464,7 @@ class DeviceMgr(ThreadJob, PrintError): if len(infos) == 1: return infos[0] msg = _("Please select which %s device to use:") % plugin.device - descriptions = [info.description for info in infos] + descriptions = [info.label + ' (%s)'%(_("initialized") if info.initialized else _("wiped")) for info in infos] return infos[handler.query_choice(msg, descriptions)] def scan_devices(self):