-
Notifications
You must be signed in to change notification settings - Fork 6
/
Download_aria.py
51 lines (40 loc) · 1.21 KB
/
Download_aria.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 20 08:58:17 2018
@author: lamarem
"""
import subprocess
import csv
import sys
from pathlib import Path
from os import chdir
# Import file containing hand sorted cloud S3 images
sat_file = Path(sys.argv[1])
cart = Path(sys.argv[2])
# Output files
outfls = Path(sys.argv[3])
# Read csv
all_dates = []
with open(str(sat_file), "r") as csvfile:
rdr = csv.reader(csvfile, delimiter=",")
next(rdr)
for row in rdr:
all_dates.append((row[0], row[1]))
baseurl = "https://scihub.copernicus.eu/s3/odata/v1/Products("
with open(str(cart), "w") as cartfile:
cartfile.write(
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
'<metalink xmlns="urn:ietf:params:xml:ns:metalink">\n'
)
for prod in all_dates:
cartfile.write(
"<file name=\"%s.zip\"><url>%s'%s')/$value</url></file>"
% (prod[0], baseurl, prod[1])
)
cartfile.write("</metalink>")
chdir(str(outfls))
commandearia = "aria2c -c --http-user=s3guest --http-passwd=s3guest"\
" --check-certificate=false --max-concurrent-downloads=2"\
" -M %s" % cart
subprocess.call(commandearia, shell=True)