commit
def109815d
|
|
@ -146,26 +146,41 @@ if __name__ == '__main__':
|
||||||
for spec in orbitMap:
|
for spec in orbitMap:
|
||||||
oType = spec[0]
|
oType = spec[0]
|
||||||
|
|
||||||
url = server + spec[1] + str(fileTS.year).zfill(2) + '/' + str(fileTS.month).zfill(2) + \
|
if oType == 'precise':
|
||||||
'/' + str(fileTS.day).zfill(2) + '/'
|
end_date = fileTS + datetime.timedelta(days=20)
|
||||||
|
elif oType == 'restituted':
|
||||||
|
end_date = fileTS
|
||||||
|
else:
|
||||||
|
raise ValueError("Unexpected orbit type: '" + oType + "'")
|
||||||
|
end_date2 = end_date + datetime.timedelta(days=1)
|
||||||
|
urls = (server + spec[1] + end_date.strftime("%Y/%m/%d/") for end_date in (end_date, end_date2))
|
||||||
|
|
||||||
success = False
|
success = False
|
||||||
match = None
|
match = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
for url in urls:
|
||||||
r = session.get(url, verify=False)
|
r = session.get(url, verify=False)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
|
|
||||||
parser = MyHTMLParser(satName, url)
|
parser = MyHTMLParser(satName, url)
|
||||||
parser.feed(r.text)
|
parser.feed(r.text)
|
||||||
|
|
||||||
for resulturl, result in parser.fileList:
|
for resulturl, result in parser.fileList:
|
||||||
|
tbef, taft, mission = fileToRange(os.path.basename(result))
|
||||||
|
if (tbef <= fileTSStart) and (taft >= fileTS):
|
||||||
match = os.path.join(resulturl, result)
|
match = os.path.join(resulturl, result)
|
||||||
|
|
||||||
if match is not None:
|
if match is not None:
|
||||||
success = True
|
success = True
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if success:
|
||||||
|
break
|
||||||
|
|
||||||
if match is not None:
|
if match is not None:
|
||||||
|
|
||||||
res = download_file(match, inps.outdir, session)
|
res = download_file(match, inps.outdir, session)
|
||||||
if res is False:
|
if res is False:
|
||||||
print('Failed to download URL: ', match)
|
print('Failed to download URL: ', match)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue