Skip to content

Commit

Permalink
Fix build URL issue (elastic#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
liza-mae authored Jan 28, 2019
1 parent 616567b commit 3d80890
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions scripts/python/lib/es_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import requests
import re
import ast
import sys
import time
from urllib.parse import urlparse


Expand Down Expand Up @@ -234,14 +236,25 @@ def architecture(self):
return translate_arch.get(platform + ' ' + ext + ' ' + arch, '')

def ping(self, url):
invalid_url = False
try:
if url:
r = requests.head(url)
if r.status_code == 200:
return True
print('Error! Invalid URL: ' + url)
r = requests.head(url)
if r.status_code == 200:
return True
if 'x-pack' not in url:
print('Status code: ' + str(r.status_code))
# Retry the invalid URL
for i in range(5):
r = requests.head(url)
print('RETRYING...Status code: ' + str(r.status_code))
if r.status_code == 200:
return True
time.sleep(1)
invalid_url = True
except:
print('Error! Unreachable URL: ' + url)
raise Exception('Error! Unreachable URL: ' + url)
if invalid_url:
raise Exception('Error! Invalid URL: ' + url)
return False

def _get_url(self, specific_url, name, parent_name='', ext=''):
Expand Down

0 comments on commit 3d80890

Please sign in to comment.