Don't throw when we fail to find a device.
Instead, set it to None and let the caller handle things. Change-Id: Ic4f27fdb52ebd6bc5b4048e4e688ec7bd2509bfa
This commit is contained in:
@@ -63,6 +63,7 @@ class ArgumentParser(argparse.ArgumentParser):
|
|||||||
msg += "\n Try specifying its location with --adb."
|
msg += "\n Try specifying its location with --adb."
|
||||||
sys.exit(msg.format(adb_path))
|
sys.exit(msg.format(adb_path))
|
||||||
|
|
||||||
|
try:
|
||||||
if result.device == "-a":
|
if result.device == "-a":
|
||||||
result.device = adb.get_device(adb_path=adb_path)
|
result.device = adb.get_device(adb_path=adb_path)
|
||||||
elif result.device == "-d":
|
elif result.device == "-d":
|
||||||
@@ -71,6 +72,9 @@ class ArgumentParser(argparse.ArgumentParser):
|
|||||||
result.device = adb.get_emulator_device(adb_path=adb_path)
|
result.device = adb.get_emulator_device(adb_path=adb_path)
|
||||||
else:
|
else:
|
||||||
result.device = adb.get_device(result.serial, adb_path=adb_path)
|
result.device = adb.get_device(result.serial, adb_path=adb_path)
|
||||||
|
except (adb.DeviceNotFoundError, adb.NoUniqueDeviceError, RuntimeError):
|
||||||
|
# Don't error out if we can't find a device.
|
||||||
|
result.device = None
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
@@ -210,6 +210,10 @@ end
|
|||||||
def main():
|
def main():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
device = args.device
|
device = args.device
|
||||||
|
|
||||||
|
if device is None:
|
||||||
|
sys.exit("ERROR: Failed to find device.")
|
||||||
|
|
||||||
props = device.get_props()
|
props = device.get_props()
|
||||||
|
|
||||||
root = os.environ["ANDROID_BUILD_TOP"]
|
root = os.environ["ANDROID_BUILD_TOP"]
|
||||||
|
|||||||
Reference in New Issue
Block a user