Mercurial > repos > stevecassidy > alveoimport
comparison alveo_data_importer.py @ 14:a38315ecf593 draft
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
author | stevecassidy |
---|---|
date | Wed, 01 Nov 2017 01:18:15 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
13:be3fd14899a1 | 14:a38315ecf593 |
---|---|
1 from __future__ import print_function | |
2 import argparse | |
3 import pyalveo | |
4 import sys | |
5 from util import API_URL, write_key | |
6 | |
7 | |
8 def parser(): | |
9 p = argparse.ArgumentParser(description="Downloads documents in an Alveo Item List") | |
10 p.add_argument('--api_key', required=True, action="store", type=str, help="Alveo API key") | |
11 p.add_argument('--item_list_url', required=True, action="store", type=str, help="Item List to download") | |
12 p.add_argument('--output', required=True, action="store", type=str, help="output file name") | |
13 p.add_argument('--outputkey', required=True, action="store", type=str, help="output file name for API Key") | |
14 return p.parse_args() | |
15 | |
16 | |
17 def main(): | |
18 args = parser() | |
19 try: | |
20 write_key(args.api_key, args.outputkey) | |
21 | |
22 client = pyalveo.Client(api_key=args.api_key, api_url=API_URL, use_cache=False) | |
23 item_list = client.get_item_list(args.item_list_url) | |
24 | |
25 with open(args.output, 'w') as out: | |
26 out.write("ItemURL\n") | |
27 for item in item_list: | |
28 out.write(item + "\n") | |
29 print(item) | |
30 | |
31 except pyalveo.APIError as e: | |
32 print("ERROR: " + str(e), file=sys.stderr) | |
33 sys.exit(1) | |
34 | |
35 | |
36 if __name__ == '__main__': | |
37 main() |