in plugin/src/py/android_screenshot_tests/pull_screenshots.py [0:0]
def main(argv):
setup_paths()
try:
opt_list, rest_args = getopt.gnu_getopt(
argv[1:],
"eds:",
[
"generate-png=",
"filter-name-regex=",
"apk",
"record=",
"verify=",
"failure-dir=",
"temp-dir=",
"no-pull",
"multiple-devices=",
"test-run-id=",
"bundle-results",
],
)
except getopt.GetoptError:
usage()
return 2
if len(rest_args) != 1:
usage()
return 2
process = rest_args[0] # something like com.facebook.places.tests
opts = dict(opt_list)
if "--apk" in opts:
# treat process as an apk instead
process = aapt.get_package(process)
should_perform_pull = "--no-pull" not in opts
bundle_results = "--bundle-results" in opts
multiple_devices = opts.get("--multiple-devices")
device_calculator = (
DeviceNameCalculator() if multiple_devices else NoOpDeviceNameCalculator()
)
base_puller_args = []
if "-e" in opts:
base_puller_args.append("-e")
if "-d" in opts:
base_puller_args.append("-d")
if "-s" in opts:
passed_serials = [opts["-s"]]
elif "ANDROID_SERIAL" in os.environ:
passed_serials = os.environ.get("ANDROID_SERIAL").split(",")
else:
passed_serials = common.get_connected_devices()
if passed_serials:
puller_args_list = [
base_puller_args + ["-s", serial] for serial in passed_serials
]
else:
puller_args_list = [base_puller_args]
for puller_args in puller_args_list:
pull_screenshots(
process,
perform_pull=should_perform_pull,
temp_dir=opts.get("--temp-dir"),
filter_name_regex=opts.get("--filter-name-regex"),
opt_generate_png=opts.get("--generate-png"),
test_run_id=opts.get("--test-run-id"),
record=opts.get("--record"),
verify=opts.get("--verify"),
adb_puller=SimplePuller(puller_args),
device_name_calculator=device_calculator,
failure_dir=opts.get("--failure-dir"),
open_html=opts.get("--open-html"),
bundle_results=bundle_results,
)