Mercurial > repos > stevecassidy > alveoimport
comparison alveo_get_item_list.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 | 56fda3d161f0 |
children |
comparison
equal
deleted
inserted
replaced
13:be3fd14899a1 | 14:a38315ecf593 |
---|---|
1 from __future__ import print_function | 1 from __future__ import print_function |
2 import json | |
3 import argparse | 2 import argparse |
4 import pyalveo | 3 import pyalveo |
5 import sys | 4 import sys |
6 import os | 5 from util import API_URL |
7 from fnmatch import fnmatch | |
8 | 6 |
9 API_URL = 'https://app.alveo.edu.au' # TODO: export constants to a separate module | |
10 | 7 |
11 def parser(): | 8 def parser(): |
12 parser = argparse.ArgumentParser(description="Downloads documents in an Alveo Item List") | 9 p = argparse.ArgumentParser(description="Downloads documents in an Alveo Item List") |
13 parser.add_argument('--api_key', required=True, action="store", type=str, help="Alveo API key") | 10 p.add_argument('--api_key', required=True, action="store", type=str, help="Alveo API key") |
14 parser.add_argument('--item_list_url', required=True, action="store", type=str, help="Item List to download") | 11 p.add_argument('--item_list_url', required=True, action="store", type=str, help="Item List to download") |
15 parser.add_argument('--output', required=True, action="store", type=str, help="output file name") | 12 p.add_argument('--output', required=True, action="store", type=str, help="output file name") |
16 return parser.parse_args() | 13 return p.parse_args() |
14 | |
17 | 15 |
18 def main(): | 16 def main(): |
19 args = parser() | 17 args = parser() |
20 try: | 18 try: |
21 api_key = open(args.api_key, 'r').read().strip() | 19 api_key = open(args.api_key, 'r').read().strip() |
25 | 23 |
26 with open(args.output, 'w') as out: | 24 with open(args.output, 'w') as out: |
27 out.write("ItemURL\n") | 25 out.write("ItemURL\n") |
28 for item in item_list: | 26 for item in item_list: |
29 out.write(item + "\n") | 27 out.write(item + "\n") |
30 print(item) | |
31 | 28 |
32 except pyalveo.APIError as e: | 29 except pyalveo.APIError as e: |
33 print("ERROR: " + str(e), file=sys.stderr) | 30 print("ERROR: " + str(e), file=sys.stderr) |
34 sys.exit(1) | 31 sys.exit(1) |
35 | 32 |
33 | |
36 if __name__ == '__main__': | 34 if __name__ == '__main__': |
37 main() | 35 main() |