2019-08-02 18:57:46 +00:00
|
|
|
# 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/.
|
|
|
|
|
|
|
|
"""
|
|
|
|
This script talks to the taskcluster secrets service to obtain the
|
|
|
|
Nimbledroid account key and upload Klar and Focus apk to Nimbledroid for perf analysis.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import taskcluster
|
|
|
|
import requests
|
|
|
|
import json
|
|
|
|
import urllib2
|
|
|
|
import os
|
2019-09-19 15:02:05 +00:00
|
|
|
import sys
|
2019-08-02 18:57:46 +00:00
|
|
|
|
|
|
|
url = "https://nimbledroid.com/api/v2/apks"
|
|
|
|
|
|
|
|
def uploadApk(apk,key):
|
|
|
|
headers = {"Accept":"*/*"}
|
|
|
|
payload = {'auto_scenarios':'false'}
|
|
|
|
response = requests.post(url, auth=(key, ''), headers=headers, files=apk, data=payload)
|
|
|
|
|
|
|
|
if response.status_code != 201:
|
|
|
|
print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
# Print Response Details
|
|
|
|
print 'Response Status Code:', response.status_code
|
|
|
|
|
|
|
|
print ''
|
|
|
|
print('Reponse Payload:')
|
|
|
|
print json.dumps(response.json(), indent=4)
|
|
|
|
|
|
|
|
|
2019-09-19 15:02:05 +00:00
|
|
|
def uploadNightlyFenixApk(apk_url, key):
|
2019-08-02 18:57:46 +00:00
|
|
|
apk_data = urllib2.urlopen(apk_url).read()
|
|
|
|
with open('./fenix_example_nd.apk', 'wb') as f:
|
2019-09-19 15:02:05 +00:00
|
|
|
f.write(apk_data)
|
2019-08-02 18:57:46 +00:00
|
|
|
uploadApk({'apk' : open('fenix_example_nd.apk')},key)
|
|
|
|
|
2019-09-19 15:02:05 +00:00
|
|
|
|
2019-08-02 18:57:46 +00:00
|
|
|
# Get JSON data from taskcluster secrets service
|
2019-09-19 15:02:05 +00:00
|
|
|
secrets = taskcluster.Secrets({
|
|
|
|
'rootUrl': os.environ.get('TASKCLUSTER_PROXY_URL', 'https://taskcluster.net'),
|
|
|
|
})
|
2019-08-02 18:57:46 +00:00
|
|
|
data = secrets.get('project/mobile/fenix/nimbledroid')
|
|
|
|
# upload the nightly build to Nimbledroid
|
2019-09-19 15:02:05 +00:00
|
|
|
apk_url = sys.argv[1]
|
|
|
|
uploadNightlyFenixApk(apk_url, data['secret']['api_key'])
|