diff options
Diffstat (limited to 'catapult/devil/devil/android/tools/script_common.py')
-rw-r--r-- | catapult/devil/devil/android/tools/script_common.py | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/catapult/devil/devil/android/tools/script_common.py b/catapult/devil/devil/android/tools/script_common.py index 150e63fb..897659bb 100644 --- a/catapult/devil/devil/android/tools/script_common.py +++ b/catapult/devil/devil/android/tools/script_common.py @@ -11,13 +11,38 @@ from devil.android import device_utils def AddEnvironmentArguments(parser): - """Adds environment-specific arguments to the provided parser.""" + """Adds environment-specific arguments to the provided parser. + + After adding these arguments, you must pass the user-specified values when + initializing devil. See the InitializeEnvironment() to determine how to do so. + + Args: + parser: an instance of argparse.ArgumentParser + """ parser.add_argument( '--adb-path', type=os.path.realpath, help='Path to the adb binary') def InitializeEnvironment(args): + """Initializes devil based on the args added by AddEnvironmentArguments(). + + This initializes devil, and configures it to use the adb binary specified by + the '--adb-path' flag (if provided by the user, otherwise this defaults to + devil's copy of adb). Although this is one possible way to initialize devil, + you should check if your project has prefered ways to initialize devil (ex. + the chromium project uses devil_chromium.Initialize() to have different + defaults for dependencies). + + This method requires having previously called AddEnvironmentArguments() on the + relevant argparse.ArgumentParser. + + Note: you should only initialize devil once, and subsequent calls to any + method wrapping devil_env.config.Initialize() will have no effect. + + Args: + args: the parsed args returned by an argparse.ArgumentParser + """ devil_dynamic_config = devil_env.EmptyConfig() if args.adb_path: devil_dynamic_config['dependencies'].update( @@ -28,7 +53,11 @@ def InitializeEnvironment(args): def AddDeviceArguments(parser): - """Adds device and blacklist arguments to the provided parser.""" + """Adds device and blacklist arguments to the provided parser. + + Args: + parser: an instance of argparse.ArgumentParser + """ parser.add_argument( '-d', '--device', dest='devices', action='append', help='Serial number of the Android device to use. (default: use all)') |