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/.
7 from datetime
import datetime
, timedelta
10 from mozperftest
.system
.android_startup
import (
20 from mozversioncontrol
import get_repository_object
23 MONO_REPO_MIGRATION_DAY
= datetime(2024, 3, 18)
26 def before_iterations(kw
):
27 product
= kw
["AndroidStartUp_product"]
28 architecture
= "arm64-v8a"
29 if product
== "geckoview_example":
30 architecture
= "aarch64"
31 if get_repository_object("").name
== "git":
32 commit_info
= subprocess
.getoutput("git log --max-count 1")
34 commit_info
= subprocess
.getoutput("hg log -l 1")
35 commit_date
= re
.search(r
"[Dd]ate:\s+([:\s\w]+)\s+", str(commit_info
)).group(1)
36 download_date
= datetime
.strptime(commit_date
, "%a %b %d %H:%M:%S %Y") - timedelta(
40 if download_date
< MONO_REPO_MIGRATION_DAY
and product
!= "geckoview_example":
41 pre_mono_repo
= "-pre-mono-repo"
42 download_date
= download_date
.strftime(DATETIME_FORMAT
)
43 if product
in MOZILLA_PRODUCTS
:
44 nightly_url
= BASE_URL_DICT
[product
+ pre_mono_repo
].format(
45 date
=download_date
, architecture
=architecture
47 filename
= f
"{product}_nightly_{architecture}.apk"
48 print("Fetching {}...".format(filename
), end
="", flush
=True)
49 download_apk_as_date(nightly_url
, download_date
, filename
)
50 print(f
"Downloaded {product} for date: {download_date}")
52 filename
= product
+ ".apk"
53 kw
["apk_metadata"] = {
55 KEY_DATETIME
: download_date
,
57 KEY_ARCHITECTURE
: architecture
,
62 def download_apk_as_date(nightly_url
, download_date_string
, filename
):
63 apk
= requests
.get(nightly_url
)
64 if apk
.status_code
!= HTTP_200_OKAY
:
66 f
"Something went wrong downloading the apk check to make sure you have entered"
67 f
" a date that is valid and that the apk for the date you have requested("
68 f
"{download_date_string}) is available and that the URL({nightly_url}) is also "
71 pathlib
.Path(filename
).write_bytes(apk
.content
)