Code review comment for lp:~zyga/linaro-image-tools/hacking

Revision history for this message
Guilherme Salgado (salgado) wrote :

Hi Zygmunt,

Thanks for your change, but I think what we really want here is to list
the selected device and all its partitions at the top of the list or
maybe even on a separate table, with proper headings instead of just "I
see...".

However, I think your changes can be an improvement, and it should be OK
to land just them if you don't have the time to do (or don't feel like
doing) the other changes. I have just a few suggestions.

First, the length of the new column is a bit too small so it feels like
instead of having two columns (Selected, and Device), we have just one
(Selected Device).

 review needsfixing

On Mon, 2011-02-14 at 12:10 +0000, Zygmunt Krynicki wrote:
[...]
> === modified file 'linaro_media_create/check_device.py'
> --- linaro_media_create/check_device.py 2011-01-28 19:50:48 +0000
> +++ linaro_media_create/check_device.py 2011-02-14 12:09:46 +0000
> @@ -65,10 +65,10 @@
> return True
>
>
> -def _print_devices():
> +def _print_devices(hilight_device=None):
> """Print disk devices found on the system."""
> bus, udisks = _get_system_bus_and_udisks_iface()
> - print '%-16s %-16s %s' % ('Device', 'Mount point', 'Size')
> + print '%-8s %-16s %-16s %s' % ('Selected', 'Device', 'Mount point', 'Size')
> devices = udisks.get_dbus_method('EnumerateDevices')()
> for path in devices:
> device = bus.get_object("org.freedesktop.UDisks", path)
> @@ -81,11 +81,13 @@
>
> if _get_dbus_property('DeviceIsPartition', device, path):
> part_size = _get_dbus_property('partition-size', device, path)
> - print '%-16s %-16s %dMB' % (
> + print '%-8s %-16s %-16s %dMB' % (
> + "------->" if hilight_device == device_file else "",

This is never going to print the marker as we're dealing with partitions
here ('DeviceIsPartition').

I'd also prefer if you used regular if/else blocks instead of the short
form here. Maybe you can even move it before the "if
_get_dbus_property()" block so that we avoid duplicating it in the else
block below?

> device_file, mount_point, part_size / 1024**2)
> else:
> device_size = _get_dbus_property('device-size', device, path)
> - print '%-16s %-16s %dMB' % (
> + print '%-8s %-16s %-16s %dMB' % (
> + "------->" if hilight_device == device_file else "",
> device_file, mount_point, device_size / 1024**2)
>
>
> @@ -121,7 +123,7 @@
> """
> if _does_device_exist(device):
> print '\nI see...'
> - _print_devices()
> + _print_devices(hilight_device=device)
> if _select_device(device):
> _ensure_device_partitions_not_mounted(device)
> return True
>

--
Guilherme Salgado <https://launchpad.net/~salgado>

review: Needs Fixing

« Back to merge proposal