Fix device size calculations in write_firmware.py

The _GetDiskCapacity() function expects the device size to be reported
as XXXX MB, but large devices have their size reported as XX.X
GB. Common for all devices is reporting the size in bytes in the end
of the string.

The regex fishing out the device size is being changed to look for the
bytes size number, then the function converts it into Gigabytes and
returns.

Some other refactoring included

 - reporting the situation where no removable devices have been found;
 - eliminating the ability to include device description as the
   command line parameter;
 - adjusting the help message
 - corrected a call site of _ExtractPayloadParts() reported as a
   problem by Lint

BUG=none
TEST=manual

  . both the following commands now work even with the cards reporting
    their size in GB:

    $ cros_write_firmware --board=peach -w sd:. -i image.bin
    $ cros_write_firmware --board=peach -w sd:/dev/sdc -i image.bin

    . when no removable device is available, the following error
      message is printed:

       No removable devices found
       Did you forget to plug in the SD card?

    . unit tests still pass
    $ FEATURES=test sudo -E emerge cros-devutils

   . when a wrong device is specified in the command line, the list of
     available devices is printed:

     $ cros_write_firmware --board=peach -w sd:/dev/sda -i image.bin
     Please specify destination -w 'sd:<disk_description>':
        - description can be . for the only disk, or
          the full device name, one of listed below:
     Found 1 available disks.
        /dev/sdc: Generic Mass Storage Device 3.9 GB

Change-Id: Ie19e34712d48179fe6ea32716d202a4ddbc1b02c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46217
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Doug Anderson <dianders@chromium.org>
1 file changed