Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions act/discovery/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import os
import textwrap
import urllib.error
import warnings
from datetime import timedelta

Expand Down Expand Up @@ -157,14 +158,19 @@ def download_arm_data(username, token, datastream, startdate, enddate, time=None
if not os.path.isdir(output_dir):
os.makedirs(output_dir)
# create file and write bytes to file
with open(output_file, 'wb') as open_bytes_file:
data = urlopen(req_save).read()
if 'This data file is not available' in str(data):
print(fname + ' is not available for download')
continue
else:
print(f'[DOWNLOADING] {fname}')
open_bytes_file.write(data)
try:
with open(output_file, 'wb') as open_bytes_file:
data = urlopen(req_save).read()
if 'This data file is not available' in str(data):
print(fname + ' is not available for download')
continue
else:
print(f'[DOWNLOADING] {fname}')
open_bytes_file.write(data)
except urllib.error.HTTPError:
print('Unable to download file: ' + fname)
os.remove(output_file)
continue
file_names.append(output_file)
# Get ARM DOI and print it out
doi = get_arm_doi(
Expand Down
Loading