annotate toolfactory/install-history.py @ 6:efefe43f23c8 draft default tip

Uploaded
author fubar
date Fri, 30 Apr 2021 02:10:32 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
1 import argparse
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
2 import os
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
3
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
4
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
5 from bioblend import galaxy
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
6
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
7
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
8 def _parser():
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
9 parser = argparse.ArgumentParser()
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
10 parser.add_argument("-g", "--galaxy", help='URL of target galaxy')
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
11 parser.add_argument("-p", "--password", help='Galaxy admin password')
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
12 parser.add_argument("-e", "--email", help='Galaxy admin email')
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
13 parser.add_argument("-a", "--key", help='Galaxy admin key', default=None)
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
14 parser.add_argument("-i", "--history_path", help='Path to history gz files to be loaded')
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
15 return parser
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
16
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
17 def main():
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
18 """
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
19 load a folder of histories or a single gz
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
20 """
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
21 args = _parser().parse_args()
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
22 if args.key:
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
23 gi = galaxy.GalaxyInstance(url=args.galaxy, key=args.key)
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
24 else:
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
25 gi = galaxy.GalaxyInstance(url=args.galaxy, email=args.email, password=args.password)
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
26 hdir = args.history_path
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
27 # h = gi.histories.get_most_recently_used_history()
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
28 if os.path.isdir(hdir):
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
29 for fp in os.listdir(hdir):
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
30 hp = os.path.join(hdir,fp)
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
31 if os.path.isfile(hp):
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
32 x = gi.histories.import_history(file_path=hp, url=None)
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
33 print('installed ',hp,'res=',x)
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
34 else:
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
35 x = gi.histories.import_history(file_path=hdir, url=None)
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
36 print('installed',hdir,'res=',x)
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
37
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
38
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
39 if __name__ == "__main__":
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
40 main()
efefe43f23c8 Uploaded
fubar
parents:
diff changeset
41