File tree 1 file changed +19
-5
lines changed
1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
2
import re
3
3
import signal
4
- import urllib . request
4
+ import requests
5
5
from contextlib import contextmanager
6
6
from dataclasses import dataclass
7
7
from datetime import datetime
@@ -195,6 +195,23 @@ def _upload_and_check_response_with_retries(apk_file_path, retries=3):
195
195
except (ConnectionError , RemoteDisconnected ):
196
196
sleep (10 )
197
197
198
+ def _download_apk (url ):
199
+ # Absolute path adde to handle CI runs.
200
+ apk_path = os .path .join (os .path .dirname (__file__ ), test_suite_data .apk_name )
201
+
202
+ try :
203
+ resp = requests .get (url )
204
+ resp .raise_for_status ()
205
+ except requests .RequestException as err :
206
+ print ('Failed GET: %s' % url )
207
+ print (resp .text )
208
+ raise err
209
+
210
+ with open (apk_path , 'wb' ) as f :
211
+ f .write (resp .content )
212
+
213
+ return apk_path
214
+
198
215
def pytest_configure (config ):
199
216
global option
200
217
option = config .option
@@ -249,10 +266,7 @@ def pytest_configure(config):
249
266
250
267
if config .getoption ('env' ) == 'sauce' and not is_uploaded ():
251
268
apk_src = config .getoption ('apk' )
252
- if apk_src .startsWith ('http' ):
253
- # Absolute path adde to handle CI runs.
254
- apk_path = os .path .join (os .path .dirname (__file__ ), test_suite_data .apk_name )
255
- urllib .request .urlretrieve (apk_src , filename = apk_path )
269
+ if apk_src .startswith ('http' ):
256
270
else :
257
271
apk_path = apk_src
258
272
You can’t perform that action at this time.
0 commit comments