main.py (2567B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 """Script that launches profiles creation.""" 5 6 import argparse 7 import os 8 import sys 9 10 # easier than setting PYTHONPATH in various platforms 11 if __name__ == "__main__": 12 sys.path.append(os.path.join(os.path.dirname(__file__), "..")) 13 14 from condprof.check_install import check # NOQA 15 16 if "MANUAL_MACH_RUN" not in os.environ: 17 check() 18 19 from condprof import patch # noqa 20 21 22 def main(args=sys.argv[1:]): 23 parser = argparse.ArgumentParser(description="Profile Creator") 24 parser.add_argument("archive", help="Archives Dir", type=str, default=None) 25 parser.add_argument("--firefox", help="Firefox Binary", type=str, default=None) 26 parser.add_argument("--scenario", help="Scenario to use", type=str, default="all") 27 parser.add_argument( 28 "--profile", help="Existing profile Dir", type=str, default=None 29 ) 30 parser.add_argument( 31 "--customization", 32 help="Profile customization to use", 33 type=str, 34 default="default", 35 ) 36 parser.add_argument( 37 "--visible", help="Don't use headless mode", action="store_true", default=False 38 ) 39 parser.add_argument( 40 "--archives-dir", help="Archives local dir", type=str, default="/tmp/archives" 41 ) 42 parser.add_argument( 43 "--force-new", help="Create from scratch", action="store_true", default=False 44 ) 45 parser.add_argument( 46 "--strict", 47 help="Errors out immediatly on a scenario failure", 48 action="store_true", 49 default=False, 50 ) 51 parser.add_argument( 52 "--geckodriver", 53 help="Path to the geckodriver binary", 54 type=str, 55 default=sys.platform.startswith("win") and "geckodriver.exe" or "geckodriver", 56 ) 57 58 parser.add_argument( 59 "--device-name", help="Name of the device", type=str, default=None 60 ) 61 62 args = parser.parse_args(args=args) 63 os.environ["CONDPROF_RUNNER"] = "1" 64 65 from condprof.runner import run # NOQA 66 67 try: 68 run( 69 args.archive, 70 args.firefox, 71 args.scenario, 72 args.profile, 73 args.customization, 74 args.visible, 75 args.archives_dir, 76 args.force_new, 77 args.strict, 78 args.geckodriver, 79 args.device_name, 80 ) 81 except Exception: 82 sys.exit(4) # TBPL_RETRY 83 84 85 if __name__ == "__main__": 86 main()