Mercurial > repos > yating-l > gonramp_apollo_tools
comparison apolloUserManager.py @ 0:ce4f91831680 draft default tip
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 5367a00befb467f162d1870edb91f9face72e894
author | yating-l |
---|---|
date | Fri, 16 Feb 2018 10:57:13 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ce4f91831680 |
---|---|
1 #!/usr/bin/env python | |
2 import os | |
3 import sys | |
4 import argparse | |
5 import json | |
6 import logging | |
7 import socket | |
8 from apollo.ApolloInstance import ApolloInstance | |
9 from apollo.ApolloUser import ApolloUser | |
10 from util.Reader import Reader | |
11 from util.Logger import Logger | |
12 | |
13 | |
14 def main(argv): | |
15 parser = argparse.ArgumentParser(description='Upload a hub to display on Apollo.') | |
16 parser.add_argument('-j', '--data_json', help='JSON file containing the metadata of the inputs') | |
17 parser.add_argument('-o', '--output', help='HTML output') | |
18 | |
19 # Get the args passed in parameter | |
20 args = parser.parse_args() | |
21 json_inputs_data = args.data_json | |
22 outputFile = args.output | |
23 | |
24 ##Parse JSON file with Reader | |
25 reader = Reader(json_inputs_data) | |
26 | |
27 # Begin init variables | |
28 | |
29 apollo_port = reader.getPortNum() | |
30 apollo_host = "http://localhost:"+ apollo_port + "/apollo" | |
31 apollo_admin_user = reader.getAdminUser() | |
32 toolDirectory = reader.getToolDir() | |
33 extra_files_path = reader.getExtFilesPath() | |
34 debug_mode = reader.getDebugMode() | |
35 operations_dictionary = reader.getOperationList() | |
36 | |
37 | |
38 | |
39 | |
40 #### Logging management #### | |
41 # If we are in Debug mode, also print in stdout the debug dump | |
42 log = Logger(tool_directory=toolDirectory, debug=debug_mode, extra_files_path=extra_files_path) | |
43 log.setup_logging() | |
44 | |
45 logging.info("#### Apollo User Manager: Start on Apollo instance: %s #### ", apollo_host) | |
46 logging.debug('JSON parameters: %s\n\n', json.dumps(reader.args)) | |
47 | |
48 # Set up apollo | |
49 apollo = ApolloInstance(apollo_host, apollo_admin_user, toolDirectory) | |
50 apollo.manageApolloUser(operations_dictionary) | |
51 outHtml(outputFile, apollo_host) | |
52 logging.info('#### Apollo User Manager: Congratulation! ####\n') | |
53 | |
54 def outHtml(outputFile, host_name): | |
55 with open(outputFile, 'w') as htmlfile: | |
56 htmlstr = 'The Apollo User Manager has done with operations on Apollo: <br>' | |
57 jbrowse_hub = '<li><a href = "%s" target="_blank">View JBrowse Hub on Apollo</a></li>' % host_name | |
58 htmlstr += jbrowse_hub | |
59 htmlfile.write(htmlstr) | |
60 | |
61 | |
62 if __name__ == "__main__": | |
63 main(sys.argv) |