brillo flash: Display progress bar at notice level for usb.
When flashing to a usb device, display the progress bar (using
pv) at logging level notice inside the chroot.
BUG=brillo:994
TEST=`cros flash usb:// IMAGE --log-level notice`
Change-Id: I284a4a557a28ae35944e36ee23179204b9e521b4
Reviewed-on: https://chromium-review.googlesource.com/269603
Reviewed-by: David Pursell <dpursell@chromium.org>
Commit-Queue: Ralph Nathan <ralphnathan@chromium.org>
Trybot-Ready: Ralph Nathan <ralphnathan@chromium.org>
Tested-by: Ralph Nathan <ralphnathan@chromium.org>
diff --git a/cli/flash.py b/cli/flash.py
index 88a4505..6d6f68d 100644
--- a/cli/flash.py
+++ b/cli/flash.py
@@ -166,7 +166,12 @@
cmd = '%s %s | dd of=%s bs=4M iflag=fullblock oflag=sync' % (
cmd_base, image, device)
- cros_build_lib.SudoRunCommand(cmd, shell=True)
+
+ # We want to display the output at logging level NOTICE or less but we only
+ # want to print the command at logging levels INFO and DEBUG.
+ cros_build_lib.SudoRunCommand(
+ cmd, shell=True, debug_level=logging.NOTICE,
+ print_cmd=logging.getLogger().getEffectiveLevel() < logging.NOTICE)
cros_build_lib.SudoRunCommand(['sync'], debug_level=self.debug_level)