| ... |
... |
@@ -7,9 +7,11 @@ import importlib.util |
|
7
|
7
|
import os
|
|
8
|
8
|
import subprocess
|
|
9
|
9
|
import sys
|
|
|
10
|
+import urllib.parse as urllib_parse
|
|
10
|
11
|
from pathlib import Path
|
|
11
|
12
|
from textwrap import dedent
|
|
12
|
13
|
|
|
|
14
|
+import requests
|
|
13
|
15
|
from mozbuild.base import BuildEnvironmentNotFoundException, MozbuildObject
|
|
14
|
16
|
from mozbuild.telemetry import filter_args
|
|
15
|
17
|
from mozfile import json
|
| ... |
... |
@@ -90,7 +92,10 @@ def is_applicable_telemetry_environment(): |
|
90
|
92
|
|
|
91
|
93
|
|
|
92
|
94
|
def is_telemetry_enabled(settings):
|
|
93
|
|
- return False
|
|
|
95
|
+ if os.environ.get("DISABLE_TELEMETRY") == "1":
|
|
|
96
|
+ return False
|
|
|
97
|
+
|
|
|
98
|
+ return settings.mach_telemetry.is_enabled
|
|
94
|
99
|
|
|
95
|
100
|
|
|
96
|
101
|
def arcrc_path():
|
| ... |
... |
@@ -127,7 +132,40 @@ def resolve_setting_from_arcconfig(topsrcdir: Path, setting): |
|
127
|
132
|
|
|
128
|
133
|
|
|
129
|
134
|
def resolve_is_employee_by_credentials(topsrcdir: Path):
|
|
130
|
|
- return None
|
|
|
135
|
+ try:
|
|
|
136
|
+ phabricator_uri = resolve_setting_from_arcconfig(topsrcdir, "phabricator.uri")
|
|
|
137
|
+
|
|
|
138
|
+ if not phabricator_uri:
|
|
|
139
|
+ return None
|
|
|
140
|
+
|
|
|
141
|
+ with arcrc_path().open() as arcrc_file:
|
|
|
142
|
+ arcrc = json.load(arcrc_file)
|
|
|
143
|
+
|
|
|
144
|
+ phabricator_token = (
|
|
|
145
|
+ arcrc.get("hosts", {})
|
|
|
146
|
+ .get(urllib_parse.urljoin(phabricator_uri, "api/"), {})
|
|
|
147
|
+ .get("token")
|
|
|
148
|
+ )
|
|
|
149
|
+
|
|
|
150
|
+ if not phabricator_token:
|
|
|
151
|
+ return None
|
|
|
152
|
+
|
|
|
153
|
+ bmo_uri = (
|
|
|
154
|
+ resolve_setting_from_arcconfig(topsrcdir, "bmo_url")
|
|
|
155
|
+ or "https://bugzilla.mozilla.org"
|
|
|
156
|
+ )
|
|
|
157
|
+ bmo_api_url = urllib_parse.urljoin(bmo_uri, "rest/whoami")
|
|
|
158
|
+ bmo_result = requests.get(
|
|
|
159
|
+ bmo_api_url, headers={"X-PHABRICATOR-TOKEN": phabricator_token}
|
|
|
160
|
+ )
|
|
|
161
|
+
|
|
|
162
|
+ return "mozilla-employee-confidential" in bmo_result.json().get("groups", [])
|
|
|
163
|
+ except (
|
|
|
164
|
+ FileNotFoundError,
|
|
|
165
|
+ json.JSONDecodeError,
|
|
|
166
|
+ requests.exceptions.RequestException,
|
|
|
167
|
+ ):
|
|
|
168
|
+ return None
|
|
131
|
169
|
|
|
132
|
170
|
|
|
133
|
171
|
def resolve_is_employee_by_vcs(topsrcdir: Path):
|