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/.
9 from mach
.decorators
import Command
, CommandArgument
10 from mozbuild
.base
import BinaryNotFoundException
12 requirements
= os
.path
.join(os
.path
.dirname(__file__
), "requirements", "base.txt")
15 def _init(command_context
):
16 command_context
.activate_virtualenv()
17 command_context
.virtualenv_manager
.install_pip_requirements(
18 requirements
, require_hashes
=False
22 @Command("fetch-condprofile", category
="testing")
23 @CommandArgument("--target-dir", default
=None, help="Target directory")
24 @CommandArgument("--platform", default
=None, help="Platform")
25 @CommandArgument("--scenario", default
="full", help="Scenario") # grab choices
26 @CommandArgument("--customization", default
="default", help="Customization") # same
27 @CommandArgument("--task-id", default
=None, help="Task ID")
28 @CommandArgument("--download-cache", action
="store_true", default
=True)
31 default
="mozilla-central",
32 choices
=["mozilla-central", "try"],
45 _init(command_context
)
46 from condprof
.client
import get_profile
47 from condprof
.util
import get_current_platform
, get_version
50 platform
= get_current_platform()
52 if target_dir
is None:
53 target_dir
= tempfile
.mkdtemp()
55 version
= get_version(command_context
.get_binary_path())
67 print("Downloaded conditioned profile can be found at: %s" % target_dir
)
70 @Command("run-condprofile", category
="testing")
71 @CommandArgument("archive", help="Archives Dir", type=str, default
=None)
72 @CommandArgument("--firefox", help="Firefox Binary", type=str, default
=None)
73 @CommandArgument("--scenario", help="Scenario to use", type=str, default
="all")
74 @CommandArgument("--profile", help="Existing profile Dir", type=str, default
=None)
76 "--customization", help="Profile customization to use", type=str, default
="all"
79 "--visible", help="Don't use headless mode", action
="store_true", default
=False
82 "--archives-dir", help="Archives local dir", type=str, default
="/tmp/archives"
85 "--force-new", help="Create from scratch", action
="store_true", default
=False
89 help="Errors out immediatly on a scenario failure",
95 help="Path to the geckodriver binary",
97 default
=sys
.platform
.startswith("win") and "geckodriver.exe" or "geckodriver",
99 @CommandArgument("--device-name", help="Name of the device", type=str, default
=None)
100 def run(command_context
, **kw
):
101 os
.environ
["MANUAL_MACH_RUN"] = "1"
102 _init(command_context
)
104 if kw
["firefox"] is None:
106 kw
["firefox"] = command_context
.get_binary_path()
107 except BinaryNotFoundException
as e
:
115 logging
.INFO
, "run-condprofile", {"help": e
.help()}, "{help}"
119 from condprof
.runner
import run