Compare commits
10 commits
11d2de4aef
...
7b49a2fde2
Author | SHA1 | Date | |
---|---|---|---|
|
7b49a2fde2 | ||
|
2d777c6369 | ||
|
cbb6838c97 | ||
|
5802e7f1a1 | ||
|
3ab555eeb6 | ||
|
d2cc85b697 | ||
|
6c082c8fe4 | ||
|
b8f178ba25 | ||
|
b63c004c32 | ||
|
51644f09db |
|
@ -32,3 +32,8 @@ Contributing
|
|||
------------
|
||||
|
||||
Contributions are welcome.
|
||||
|
||||
Other
|
||||
-----
|
||||
|
||||
Reference Implementation in Java: https://github.com/icann/czds-api-client-java
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"icann.account.username": "username@example.com",
|
||||
"icann.account.password": "Abcdef#12345678",
|
||||
"authentication.base.url": "https://account-api-test.icann.org",
|
||||
"czds.base.url": "https://czds-api-test.icann.org",
|
||||
"authentication.base.url": "https://account-api.icann.org",
|
||||
"czds.base.url": "https://czds-api.icann.org",
|
||||
"working.directory": "/where/zonefiles/will/be/saved"
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@ def do_get(url, access_token):
|
|||
'Accept': 'application/json',
|
||||
'Authorization': 'Bearer {0}'.format(access_token)}
|
||||
|
||||
response = requests.get(url, params=None, headers=bearer_headers)
|
||||
response = requests.get(url, params=None, headers=bearer_headers, stream=True)
|
||||
|
||||
return response
|
||||
|
|
18
download.py
18
download.py
|
@ -12,9 +12,13 @@ from do_http_get import do_get
|
|||
##############################################################################################################
|
||||
|
||||
try:
|
||||
config_file = open("config.json", "r")
|
||||
config = json.load(config_file)
|
||||
config_file.close()
|
||||
if 'CZDS_CONFIG' in os.environ:
|
||||
config_data = os.environ['CZDS_CONFIG']
|
||||
config = json.loads(config_data)
|
||||
else:
|
||||
config_file = open("config.json", "r")
|
||||
config = json.load(config_file)
|
||||
config_file.close()
|
||||
except:
|
||||
sys.stderr.write("Error loading config.json file.\n")
|
||||
exit(1)
|
||||
|
@ -26,7 +30,7 @@ authen_base_url = config['authentication.base.url']
|
|||
czds_base_url = config['czds.base.url']
|
||||
|
||||
# This is optional. Default to current directory
|
||||
working_directory = config['working.directory']
|
||||
working_directory = config.get('working.directory', '.') # Default to current directory
|
||||
|
||||
if not username:
|
||||
sys.stderr.write("'icann.account.username' parameter not found in the config.json file\n")
|
||||
|
@ -44,10 +48,6 @@ if not czds_base_url:
|
|||
sys.stderr.write("'czds.base.url' parameter not found in the config.json file\n")
|
||||
exit(1)
|
||||
|
||||
if not working_directory:
|
||||
# Default to current directory
|
||||
working_directory = '.'
|
||||
|
||||
|
||||
|
||||
##############################################################################################################
|
||||
|
@ -109,7 +109,7 @@ def download_one_zone(url, output_directory):
|
|||
if status_code == 200:
|
||||
# Try to get the filename from the header
|
||||
_,option = cgi.parse_header(download_zone_response.headers['content-disposition'])
|
||||
filename = option['filename']
|
||||
filename = option.get('filename')
|
||||
|
||||
# If could get a filename from the header, then makeup one like [tld].txt.gz
|
||||
if not filename:
|
||||
|
|
Loading…
Reference in a new issue