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 (
23 def before_iterations(kw
):
24 product
= kw
["AndroidStartUp_product"]
25 architecture
= "arm64-v8a"
26 if product
== "geckoview_example":
27 architecture
= "aarch64"
28 commit_info
= subprocess
.getoutput("hg log -l 1")
29 commit_date
= re
.search(r
"date:\s+([:\s\w]+)\s+", str(commit_info
)).group(1)
31 datetime
.strptime(commit_date
, "%a %b %d %H:%M:%S %Y") - timedelta(days
=1)
32 ).strftime(DATETIME_FORMAT
)
34 nightly_url
= BASE_URL_DICT
[product
].format(
35 date
=download_date
, architecture
=architecture
37 filename
= f
"{product}_nightly_{architecture}.apk"
38 print("Fetching {}...".format(filename
), end
="", flush
=True)
39 download_apk_as_date(nightly_url
, download_date
, filename
)
40 print(f
"Downloaded {product} for date: {download_date}")
42 kw
["apk_metadata"] = {
44 KEY_DATETIME
: download_date
,
46 KEY_ARCHITECTURE
: architecture
,
51 def download_apk_as_date(nightly_url
, download_date_string
, filename
):
52 apk
= requests
.get(nightly_url
)
53 if apk
.status_code
!= HTTP_200_OKAY
:
55 f
"Something went wrong downloading the apk check to make sure you have entered"
56 f
" a date that is valid and that the apk for the date you have requested("
57 f
"{download_date_string}) is available and that the URL({nightly_url}) is also "
60 pathlib
.Path(filename
).write_bytes(apk
.content
)