CLI: Add default device targeting.
Adds default device targeting to brillo debug/deploy/flash/shell, so
that if --device isn't specified it will try to auto-detect the USB
connected device.
The logging and error messages probably need to be cleaned up a bit in a
future CL, this is just to get the functionality plugged in.
BUG=brillo:82
TEST=cbuildbot/run_tests
Change-Id: I72e1911f40bc2e21c4b21102827740e3c694a3ac
Reviewed-on: https://chromium-review.googlesource.com/263989
Reviewed-by: David Pursell <dpursell@chromium.org>
Tested-by: David Pursell <dpursell@chromium.org>
Commit-Queue: David Pursell <dpursell@chromium.org>
diff --git a/cli/flash.py b/cli/flash.py
index ef92dc5..dd675a6 100644
--- a/cli/flash.py
+++ b/cli/flash.py
@@ -670,7 +670,7 @@
same underlying functionality.
Args:
- device: A commandline.Device object to target.
+ device: commandline.Device object; None to use the default device.
image: Path (string) to the update image. Can be a local or xbuddy path;
non-existant local paths are converted to xbuddy.
project_sdk_image: Use a clean project SDK image. Overrides |image| if True.
@@ -709,7 +709,7 @@
logging.error('Failed to create %s', _DEVSERVER_STATIC_DIR)
if install:
- if device.scheme != commandline.DEVICE_SCHEME_USB:
+ if not device or device.scheme != commandline.DEVICE_SCHEME_USB:
raise ValueError(
'--install can only be used when writing to a USB device')
if not cros_build_lib.IsInsideChroot():
@@ -727,11 +727,15 @@
if brick:
board = brick.FriendlyName()
- if device.scheme == commandline.DEVICE_SCHEME_SSH:
- logging.info('Preparing to update the remote device %s', device.hostname)
+ if not device or device.scheme == commandline.DEVICE_SCHEME_SSH:
+ if device:
+ hostname, port = device.hostname, device.port
+ else:
+ hostname, port = None, None
+ logging.info('Preparing to update the remote device %s', hostname)
updater = RemoteDeviceUpdater(
- device.hostname,
- device.port,
+ hostname,
+ port,
image,
board=board,
brick=brick,