0
|
1 #!/usr/bin/env python
|
|
2
|
|
3 import argparse
|
|
4 import re
|
|
5 import urllib2
|
|
6
|
|
7
|
|
8 def main():
|
|
9 parser = argparse.ArgumentParser()
|
|
10 parser.add_argument("dataHub", type=str)
|
|
11 parser.add_argument("datasetId", type=str)
|
|
12 parser.add_argument("datafile", type=str)
|
|
13 args = parser.parse_args()
|
|
14
|
|
15 datasetUrlHost = re.sub("/proj/", "/download/", args.dataHub)
|
|
16 datasetIdTokens = re.split("/", args.datasetId)
|
|
17 datasetUrl = datasetUrlHost + "/" + "/".join(datasetIdTokens[1:])
|
50
|
18
|
|
19 data = open(args.datafile, "w")
|
|
20
|
|
21 try:
|
|
22 dd = urllib2.urlopen(datasetUrl)
|
0
|
23 data.write(dd.read())
|
50
|
24 dd.close()
|
|
25 data.close()
|
|
26 except:
|
|
27 data.wriet("You entered dataset id: %s\n" % (args.datasetId))
|
|
28 data.write("Dataset does not exist. check typo.")
|
|
29 data.close()
|
|
30 sys.exit(1)
|
0
|
31
|
|
32 if __name__ == "__main__":
|
|
33 main()
|
|
34
|