6 import xml
.etree
.ElementTree
as ET
12 print("Usage: dl-test-assets.py <path to assets.xml> <base url> <output dir>")
15 infile_name
= sys
.argv
[1]
16 base_url
= sys
.argv
[2]
18 tree
= ET
.parse(infile_name
)
21 if not os
.path
.exists(outdir
):
24 def downloadAsset(elem
):
25 if elem
.tag
!= "Blob":
27 id = elem
.attrib
["Id"]
28 filename
= os
.path
.basename(id)
29 print "Downloading " + filename
31 name
, hdrs
= urllib
.urlretrieve(base_url
+ "/" + id, outdir
+ "/" + filename
)
33 print ("Download failed for " + id)
35 print "Extracting " + filename
36 with zipfile
.ZipFile(outdir
+ "/" + filename
) as zf
:
37 zf
.extractall(outdir
+ "/extracted/" + filename
[:-4])
39 pool
= multiprocessing
.Pool(multiprocessing
.cpu_count())
40 results
= pool
.map(downloadAsset
, root
)