Mercurial > repos > fabio > gdcwebapp
comparison jcds_wrapper.py @ 44:bab44ade984c draft
Uploaded 20170622
author | fabio |
---|---|
date | Thu, 22 Jun 2017 16:34:10 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
43:73d593ff91e4 | 44:bab44ade984c |
---|---|
1 #!/usr/bin/env python | |
2 import json_collect_data_source as jcds | |
3 import optparse | |
4 | |
5 __version__ = "1.0.0" | |
6 | |
7 def __main__(): | |
8 """ Read the JSON return from a data source. Parse each line and request | |
9 the data, download to "newfilepath", and write metadata. | |
10 | |
11 Schema | |
12 ------ | |
13 | |
14 [ {"url":"http://url/to/file.tar.gz", | |
15 "name":"My Archive", | |
16 "extension":"tar.gz", | |
17 "organize":"true", | |
18 "metadata":{"db_key":"hg38"}, | |
19 "extra_data":[ {"url":"http://url_of_ext_file", | |
20 "path":"rel/path/to/ext_file"} | |
21 ] | |
22 } | |
23 ] | |
24 | |
25 """ | |
26 # Parse the command line options | |
27 usage = "Usage: jcds_wrapper.py max_size --json_param_file filename [options]" | |
28 parser = optparse.OptionParser(usage = usage) | |
29 parser.add_option("-j", "--json_param_file", type="string", | |
30 action="store", dest="json_param_file", help="json schema return data") | |
31 parser.add_option("-p", "--path", type="string", | |
32 action="store", dest="path", help="new file path") | |
33 # set appdata: temporary directory in which the archives will be decompressed | |
34 parser.add_option("-a", "--appdata", type="string", | |
35 action="store", dest="appdata", help="appdata folder name") | |
36 parser.add_option("-v", "--version", action="store_true", dest="version", | |
37 default=False, help="display version and exit") | |
38 | |
39 (options, args) = parser.parse_args() | |
40 if options.version: | |
41 print __version__ | |
42 else: | |
43 jcds.download_from_json_data( options, args ) | |
44 | |
45 | |
46 if __name__ == "__main__": __main__() |