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 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":"*/*"}
|
2019-12-18 16:40:35 +00:00
|
|
|
payload = {'auto_scenarios':'false', 'device_config': 'android5,android7'}
|
2019-08-02 18:57:46 +00:00
|
|
|
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-11-08 13:19:10 +00:00
|
|
|
apk_path = sys.argv[1]
|
|
|
|
token_file = sys.argv[2]
|
2019-08-02 18:57:46 +00:00
|
|
|
|
2019-11-08 13:19:10 +00:00
|
|
|
with open(token_file) as f:
|
|
|
|
key = f.read()
|
2019-09-19 15:02:05 +00:00
|
|
|
|
2019-11-08 13:19:10 +00:00
|
|
|
with open(apk_path) as apk_file:
|
|
|
|
uploadApk({'apk': apk_file}, key)
|