summaryrefslogtreecommitdiffstats
path: root/testing/condprofile/condprof/main.py
blob: 16a848683e4c15285d04fecf4f14d4a830018e8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
""" Script that launches profiles creation.
"""
from __future__ import absolute_import
import os
import argparse
import sys

# easier than setting PYTHONPATH in various platforms
if __name__ == "__main__":
    sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

from condprof.check_install import check  # NOQA

if "MANUAL_MACH_RUN" not in os.environ:
    check()

PY3 = sys.version_info.major == 3

if PY3:
    from condprof import patch  # noqa


def main(args=sys.argv[1:]):
    parser = argparse.ArgumentParser(description="Profile Creator")
    parser.add_argument("archive", help="Archives Dir", type=str, default=None)
    parser.add_argument("--firefox", help="Firefox Binary", type=str, default=None)
    parser.add_argument("--scenario", help="Scenario to use", type=str, default="all")
    parser.add_argument(
        "--profile", help="Existing profile Dir", type=str, default=None
    )
    parser.add_argument(
        "--customization", help="Profile customization to use", type=str, default="all"
    )
    parser.add_argument(
        "--visible", help="Don't use headless mode", action="store_true", default=False
    )
    parser.add_argument(
        "--archives-dir", help="Archives local dir", type=str, default="/tmp/archives"
    )
    parser.add_argument(
        "--force-new", help="Create from scratch", action="store_true", default=False
    )
    parser.add_argument(
        "--strict",
        help="Errors out immediatly on a scenario failure",
        action="store_true",
        default=True,
    )
    parser.add_argument(
        "--geckodriver",
        help="Path to the geckodriver binary",
        type=str,
        default=sys.platform.startswith("win") and "geckodriver.exe" or "geckodriver",
    )

    parser.add_argument(
        "--device-name", help="Name of the device", type=str, default=None
    )

    args = parser.parse_args(args=args)
    os.environ["CONDPROF_RUNNER"] = "1"

    from condprof.runner import run  # NOQA

    run(
        args.archive,
        args.firefox,
        args.scenario,
        args.profile,
        args.customization,
        args.visible,
        args.archives_dir,
        args.force_new,
        args.strict,
        args.geckodriver,
        args.device_name,
    )


if __name__ == "__main__":
    main()