1#!/usr/bin/python 2# 3# Copyright 2016 The Chromium OS Authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7'''Make Chrome automatically log in.''' 8 9# This sets up import paths for autotest. 10import common 11 12import argparse 13import getpass 14import sys 15 16from autotest_lib.client.common_lib.cros import chrome 17 18 19def main(args): 20 '''The main function. 21 22 @param args: list of string args passed to program 23 ''' 24 25 parser = argparse.ArgumentParser(description=__doc__) 26 parser.add_argument('-a', '--arc', action='store_true', 27 help='Enable ARC and wait for it to start.') 28 parser.add_argument('-d', '--dont_override_profile', action='store_true', 29 help='Keep files from previous sessions.') 30 parser.add_argument('-u', '--username', 31 help='Log in as provided username.') 32 args = parser.parse_args(args) 33 34 if args.username: 35 password = getpass.getpass() 36 37 # Avoid calling close() on the Chrome object; this keeps the session active. 38 chrome.Chrome( 39 arc_mode=('enabled' if args.arc else None), 40 username=args.username, 41 password=(password if args.username else None), 42 gaia_login=(args.username is not None), 43 dont_override_profile=args.dont_override_profile) 44 45 46if __name__ == '__main__': 47 sys.exit(main(sys.argv[1:])) 48