update from Atlas
This commit is contained in:
@@ -5,8 +5,8 @@ import time
|
||||
|
||||
times = {}
|
||||
|
||||
def fetch(iso_cc):
|
||||
resp = requests.get(cf.flag_url(iso_cc))
|
||||
def fetch(iso_cc, source):
|
||||
resp = requests.get(cf.flag_url(iso_cc, source))
|
||||
if resp.status_code != 200:
|
||||
resp.raise_for_status()
|
||||
file_name = cf.iso_file_name(iso_cc)
|
||||
@@ -14,7 +14,7 @@ def fetch(iso_cc):
|
||||
written = img.write(resp.content)
|
||||
return written, file_name
|
||||
|
||||
def main():
|
||||
def main(source):
|
||||
pending = sorted(cf.cc2name)
|
||||
to_download = len(pending)
|
||||
downloaded = 0
|
||||
@@ -23,7 +23,7 @@ def main():
|
||||
print('get:', iso_cc)
|
||||
try:
|
||||
times[iso_cc] = [time.time() - t0]
|
||||
octets, file_name = fetch(iso_cc)
|
||||
octets, file_name = fetch(iso_cc, source)
|
||||
times[iso_cc].append(time.time() - t0)
|
||||
downloaded += 1
|
||||
print('\t--> {}: {:5d} bytes'.format(file_name, octets))
|
||||
@@ -36,7 +36,14 @@ def main():
|
||||
print('{}\t{:.6g}\t{:.6g}'.format(iso_cc, start, end))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
import argparse
|
||||
|
||||
source_names = ', '.join(sorted(cf.SOURCE_URLS))
|
||||
parser = argparse.ArgumentParser(description='Download flag images.')
|
||||
parser.add_argument('source', help='one of: ' + source_names)
|
||||
|
||||
args = parser.parse_args()
|
||||
main(args.source)
|
||||
|
||||
"""
|
||||
From cia.gov:
|
||||
@@ -53,4 +60,4 @@ From localhost nginx via Vaurien with .5s delay
|
||||
real 1m40.519s
|
||||
user 0m1.103s
|
||||
sys 0m0.243s
|
||||
"""
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user