diff options
Diffstat (limited to 'catapult/devil/devil/android/tools/script_common.py')
-rw-r--r-- | catapult/devil/devil/android/tools/script_common.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/catapult/devil/devil/android/tools/script_common.py b/catapult/devil/devil/android/tools/script_common.py index f91ad5ee..150e63fb 100644 --- a/catapult/devil/devil/android/tools/script_common.py +++ b/catapult/devil/devil/android/tools/script_common.py @@ -2,12 +2,41 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import os + +from devil import devil_env from devil.android import device_blacklist from devil.android import device_errors from devil.android import device_utils +def AddEnvironmentArguments(parser): + """Adds environment-specific arguments to the provided parser.""" + parser.add_argument( + '--adb-path', type=os.path.realpath, + help='Path to the adb binary') + + +def InitializeEnvironment(args): + devil_dynamic_config = devil_env.EmptyConfig() + if args.adb_path: + devil_dynamic_config['dependencies'].update( + devil_env.LocalConfigItem( + 'adb', devil_env.GetPlatform(), args.adb_path)) + + devil_env.config.Initialize(configs=[devil_dynamic_config]) + + +def AddDeviceArguments(parser): + """Adds device and blacklist arguments to the provided parser.""" + parser.add_argument( + '-d', '--device', dest='devices', action='append', + help='Serial number of the Android device to use. (default: use all)') + parser.add_argument('--blacklist-file', help='Device blacklist JSON file.') + + def GetDevices(requested_devices, blacklist_file): + """Gets a list of healthy devices matching the given parameters.""" if not isinstance(blacklist_file, device_blacklist.Blacklist): blacklist_file = (device_blacklist.Blacklist(blacklist_file) if blacklist_file |