Skip to content

Commit

Permalink
chore: retry for the meta dumper a few times (#14242)
Browse files Browse the repository at this point in the history
  • Loading branch information
trop[bot] authored and MarshallOfSound committed Aug 21, 2018
1 parent ed8396c commit a1ac930
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions script/upload-index-json.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@
version = sys.argv[1]
authToken = os.getenv('META_DUMPER_AUTH_HEADER')

def get_content(retry_count = 5):
try:
request = urllib2.Request(
BASE_URL + version,
headers={"Authorization" : authToken}
)

return urllib2.urlopen(
request
).read()
except Exception as e:
if retry_count == 0:
raise e
return get_content(retry_count - 1)

def main():
if not authToken or authToken == "":
raise Exception("Please set META_DUMPER_AUTH_HEADER")
Expand All @@ -23,14 +38,7 @@ def main():
safe_mkdir(OUT_DIR)
index_json = os.path.relpath(os.path.join(OUT_DIR, 'index.json'))

request = urllib2.Request(
BASE_URL + version,
headers={"Authorization" : authToken}
)

new_content = urllib2.urlopen(
request
).read()
new_content = get_content()

with open(index_json, "w") as f:
f.write(new_content)
Expand Down

0 comments on commit a1ac930

Please sign in to comment.