Mercurial > repos > fubar > tool_factory_2
comparison toolfactory/install-history.py @ 3:1c652687a08f draft default tip
Uploaded
| author | fubar |
|---|---|
| date | Fri, 30 Apr 2021 07:06:57 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 2:5fc0c9a93072 | 3:1c652687a08f |
|---|---|
| 1 import argparse | |
| 2 import os | |
| 3 | |
| 4 | |
| 5 from bioblend import galaxy | |
| 6 | |
| 7 | |
| 8 def _parser(): | |
| 9 parser = argparse.ArgumentParser() | |
| 10 parser.add_argument("-g", "--galaxy", help='URL of target galaxy') | |
| 11 parser.add_argument("-p", "--password", help='Galaxy admin password') | |
| 12 parser.add_argument("-e", "--email", help='Galaxy admin email') | |
| 13 parser.add_argument("-a", "--key", help='Galaxy admin key', default=None) | |
| 14 parser.add_argument("-i", "--history_path", help='Path to history gz files to be loaded') | |
| 15 return parser | |
| 16 | |
| 17 def main(): | |
| 18 """ | |
| 19 load a folder of histories or a single gz | |
| 20 """ | |
| 21 args = _parser().parse_args() | |
| 22 if args.key: | |
| 23 gi = galaxy.GalaxyInstance(url=args.galaxy, key=args.key) | |
| 24 else: | |
| 25 gi = galaxy.GalaxyInstance(url=args.galaxy, email=args.email, password=args.password) | |
| 26 hdir = args.history_path | |
| 27 # h = gi.histories.get_most_recently_used_history() | |
| 28 if os.path.isdir(hdir): | |
| 29 for fp in os.listdir(hdir): | |
| 30 hp = os.path.join(hdir,fp) | |
| 31 if os.path.isfile(hp): | |
| 32 x = gi.histories.import_history(file_path=hp, url=None) | |
| 33 print('installed ',hp,'res=',x) | |
| 34 else: | |
| 35 x = gi.histories.import_history(file_path=hdir, url=None) | |
| 36 print('installed',hdir,'res=',x) | |
| 37 | |
| 38 | |
| 39 if __name__ == "__main__": | |
| 40 main() | |
| 41 |
