def main():
parser = ArgumentParser()<EOL>subs = parser.add_subparsers(dest='<STR_LIT>')<EOL>setup_parser = subs.add_parser('<STR_LIT>')<EOL>setup_parser.add_argument('<STR_LIT>', '<STR_LIT>', dest='<STR_LIT:email>', required=True,<EOL>help='<STR_LIT>', type=str)<EOL>setup_parser.add_argument('<STR_LIT>', '<STR_LIT>', dest='<STR_LIT>', required=True,<EOL>help='<STR_LIT>', type=str)<EOL>setup_parser = subs.add_parser('<STR_LIT>')<EOL>setup_parser.add_argument('<STR_LIT>', '<STR_LIT>', dest='<STR_LIT>',<EOL>required=True, type=str,<EOL>help='<STR_LIT>',)<EOL>setup_parser = subs.add_parser('<STR_LIT:list>')<EOL>setup_parser = subs.add_parser('<STR_LIT>')<EOL>setup_parser.add_argument('<STR_LIT>', '<STR_LIT>', dest='<STR_LIT>', required=True,<EOL>help='<STR_LIT>', type=str)<EOL>setup_parser.add_argument('<STR_LIT>', dest='<STR_LIT>', action='<STR_LIT:store_true>',<EOL>help='<STR_LIT>')<EOL>setup_parser.add_argument('<STR_LIT>', '<STR_LIT>', dest='<STR_LIT>',<EOL>required=True, choices=['<STR_LIT>', '<STR_LIT>'],<EOL>help='<STR_LIT>')<EOL>setup_parser.add_argument('<STR_LIT>', '<STR_LIT>', dest='<STR_LIT>',<EOL>default="<STR_LIT>", choices=['<STR_LIT>', '<STR_LIT>', '<STR_LIT>'],<EOL>help='<STR_LIT>')<EOL>setup_parser = subs.add_parser('<STR_LIT>')<EOL>setup_parser.add_argument('<STR_LIT>', dest='<STR_LIT>', required=True,<EOL>help='<STR_LIT>',<EOL>type=str)<EOL>args = parser.parse_args()<EOL>if args.cmd == '<STR_LIT>':<EOL><INDENT>if not os.path.exists(CONFIG_PATH):<EOL><INDENT>os.makedirs(CONFIG_PATH)<EOL><DEDENT>if not os.path.exists(CONFIG_FILE):<EOL><INDENT>json.dump(CONFIG_DEFAULTS, open(CONFIG_FILE, '<STR_LIT:w>'), indent=<NUM_LIT:4>,<EOL>separators=('<STR_LIT:U+002C>', '<STR_LIT>'))<EOL><DEDENT>config = CONFIG_DEFAULTS<EOL>config['<STR_LIT:email>'] = args.email<EOL>config['<STR_LIT:password>'] = str(obfuscate(args.pwd, '<STR_LIT:store>'))<EOL>json.dump(config, open(CONFIG_FILE, '<STR_LIT:w>'), indent=<NUM_LIT:4>,<EOL>separators=('<STR_LIT:U+002C>', '<STR_LIT>'))<EOL><DEDENT>config = json.load(open(CONFIG_FILE))<EOL>if config.get('<STR_LIT>', PY2) != PY2:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>if config['<STR_LIT:password>'] == '<STR_LIT>':<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>if args.cmd == '<STR_LIT>':<EOL><INDENT>config['<STR_LIT:password>'] = obfuscate(str(config['<STR_LIT:password>']), '<STR_LIT>')<EOL>ga = GoogleAlerts(config['<STR_LIT:email>'], config['<STR_LIT:password>'])<EOL>with contextlib.closing(webdriver.Chrome(args.driver)) as driver:<EOL><INDENT>driver.get(ga.LOGIN_URL)<EOL>wait = ui.WebDriverWait(driver, <NUM_LIT:10>) <EOL>inputElement = driver.find_element_by_name('<STR_LIT>')<EOL>inputElement.send_keys(config['<STR_LIT:email>'])<EOL>inputElement.submit()<EOL>time.sleep(<NUM_LIT:3>)<EOL>inputElement = driver.find_element_by_id('<STR_LIT>')<EOL>inputElement.send_keys(config['<STR_LIT:password>'])<EOL>inputElement.submit()<EOL>print("<STR_LIT>")<EOL>time.sleep(<NUM_LIT:15>)<EOL>cookies = driver.get_cookies()<EOL>collected = dict()<EOL>for cookie in cookies:<EOL><INDENT>collected[str(cookie['<STR_LIT:name>'])] = str(cookie['<STR_LIT:value>'])<EOL><DEDENT>with open(SESSION_FILE, '<STR_LIT:wb>') as f:<EOL><INDENT>pickle.dump(collected, f, protocol=<NUM_LIT:2>)<EOL><DEDENT><DEDENT>print("<STR_LIT>")<EOL><DEDENT>if args.cmd == '<STR_LIT:list>':<EOL><INDENT>config['<STR_LIT:password>'] = obfuscate(str(config['<STR_LIT:password>']), '<STR_LIT>')<EOL>ga = GoogleAlerts(config['<STR_LIT:email>'], config['<STR_LIT:password>'])<EOL>ga.authenticate()<EOL>print(json.dumps(ga.list(), indent=<NUM_LIT:4>))<EOL><DEDENT>if args.cmd == '<STR_LIT>':<EOL><INDENT>config['<STR_LIT:password>'] = obfuscate(str(config['<STR_LIT:password>']), '<STR_LIT>')<EOL>ga = GoogleAlerts(config['<STR_LIT:email>'], config['<STR_LIT:password>'])<EOL>ga.authenticate()<EOL>alert_frequency = '<STR_LIT>'<EOL>if args.frequency == '<STR_LIT>':<EOL><INDENT>alert_frequency = '<STR_LIT>'<EOL><DEDENT>elif args.frequency == '<STR_LIT>':<EOL><INDENT>alert_frequency = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>alert_frequency = '<STR_LIT>'<EOL><DEDENT>monitor = ga.create(args.term, {'<STR_LIT>': args.delivery.upper(),<EOL>'<STR_LIT>': alert_frequency.upper(),<EOL>'<STR_LIT>': args.exact})<EOL>print(json.dumps(monitor, indent=<NUM_LIT:4>))<EOL><DEDENT>if args.cmd == '<STR_LIT>':<EOL><INDENT>config['<STR_LIT:password>'] = obfuscate(str(config['<STR_LIT:password>']), '<STR_LIT>')<EOL>ga = GoogleAlerts(config['<STR_LIT:email>'], config['<STR_LIT:password>'])<EOL>ga.authenticate()<EOL>result = ga.delete(args.term_id)<EOL>if result:<EOL><INDENT>print("<STR_LIT>" % args.term_id)<EOL><DEDENT><DEDENT>
Run the core.