Mercurial > repos > stevecassidy > alveoimport
comparison alveo_data_importer.py @ 18:5e1b7d922ea3 draft default tip
planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit 53cde5cc9b8c1adcccdc3cfa52d8ca82079aeda7
| author | stevecassidy |
|---|---|
| date | Mon, 15 Jan 2018 18:34:57 -0500 |
| parents | b69f6d41d17c |
| children |
comparison
equal
deleted
inserted
replaced
| 17:b69f6d41d17c | 18:5e1b7d922ea3 |
|---|---|
| 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() |
