Commit 58576bf8 authored by José Henrique's avatar José Henrique
Browse files

Implement attempts when trying to download incremental artifact

parent 4b57004d
......@@ -7,6 +7,7 @@ import hashlib
import ftplib
import requests
import re
import time
from zipfile import ZipFile
......@@ -137,11 +138,21 @@ def get_artifact_info(device, build):
"device": device,
"build": build
}
response = requests.request("POST", api_url, data=post_data)
assert response.status_code == 200
response = response.json()
if not response["error"] and response["available"]:
return response["md5_hash"]
for i in range(1, 6):
print("Connecting to " + api_url + " (" + str(i) + "/5)")
try:
response = requests.request("POST", api_url, data=post_data)
status_code = response.status_code
assert status_code == 200
response = response.json()
if not response["error"] and response["available"]:
return response["md5_hash"]
break
except AssertionError:
print("Failed, server returned: " +
str(status_code) + ", trying again...")
pass
time.sleep(5)
return False
......@@ -153,11 +164,16 @@ def download_artifact(device, build, destination_path):
" --data-urlencode 'device=" + device + "'" + \
" --data-urlencode 'build=" + build + "'" + \
" --output '" + destination_path + "'"
result = run_command(cmd)
if result != 0:
sys.exit(
"Failed to download artifact, process returned code " +
str(result))
for i in range(1, 6):
print("Trying to download artifact (" + str(i) + "/5)")
if run_command(cmd) == 0:
return True
print("Download failed, trying again...")
time.sleep(5)
sys.exit(
"Failed to download artifact, process returned code " +
str(result))
def validate_release_tools(release_tools_path):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment