File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed
Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change 1515version = sys .argv [1 ]
1616authToken = os .getenv ('META_DUMPER_AUTH_HEADER' )
1717
18+ def get_content (retry_count = 5 ):
19+ try :
20+ request = urllib2 .Request (
21+ BASE_URL + version ,
22+ headers = {"Authorization" : authToken }
23+ )
24+
25+ return urllib2 .urlopen (
26+ request
27+ ).read ()
28+ except Exception as e :
29+ if retry_count == 0 :
30+ raise e
31+ return get_content (retry_count - 1 )
32+
1833def main ():
1934 if not authToken or authToken == "" :
2035 raise Exception ("Please set META_DUMPER_AUTH_HEADER" )
@@ -23,14 +38,7 @@ def main():
2338 safe_mkdir (OUT_DIR )
2439 index_json = os .path .relpath (os .path .join (OUT_DIR , 'index.json' ))
2540
26- request = urllib2 .Request (
27- BASE_URL + version ,
28- headers = {"Authorization" : authToken }
29- )
30-
31- new_content = urllib2 .urlopen (
32- request
33- ).read ()
41+ new_content = get_content ()
3442
3543 with open (index_json , "w" ) as f :
3644 f .write (new_content )
You can’t perform that action at this time.
0 commit comments