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