Mercurial > repos > yating-l > suite_gonramp_apollo2
annotate apolloUserManager.py @ 0:9945eba268e6 draft default tip
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
author | yating-l |
---|---|
date | Mon, 27 Nov 2017 12:49:27 -0500 |
parents | |
children |
rev | line source |
---|---|
0
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
1 #!/usr/bin/env python |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
2 import os |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
3 import sys |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
4 import argparse |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
5 import json |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
6 import logging |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
7 import socket |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
8 from apollo.ApolloInstance import ApolloInstance |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
9 from apollo.ApolloUser import ApolloUser |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
10 from util.Reader import Reader |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
11 from util.Logger import Logger |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
12 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
13 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
14 def main(argv): |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
15 parser = argparse.ArgumentParser(description='Upload a hub to display on Apollo.') |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
16 parser.add_argument('-j', '--data_json', help='JSON file containing the metadata of the inputs') |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
17 parser.add_argument('-o', '--output', help='HTML output') |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
18 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
19 # Get the args passed in parameter |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
20 args = parser.parse_args() |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
21 json_inputs_data = args.data_json |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
22 outputFile = args.output |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
23 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
24 ##Parse JSON file with Reader |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
25 reader = Reader(json_inputs_data) |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
26 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
27 # Begin init variables |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
28 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
29 apollo_port = reader.getPortNum() |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
30 apollo_host = "http://localhost:"+ apollo_port + "/apollo" |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
31 apollo_admin_user = reader.getAdminUser() |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
32 toolDirectory = reader.getToolDir() |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
33 debug_mode = reader.getDebugMode() |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
34 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
35 operations_dictionary = reader.getOperationList() |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
36 #OPERATIONS = ['create', 'delete', 'add', 'remove'] |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
37 #create_user_list = reader.getOperationList("create") |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
38 #delete_user_list = reader.getOperationList("delete") |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
39 #remove_user_list = reader.getOperationList("remove") |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
40 #add_user_list = reader.getOperationList("add") |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
41 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
42 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
43 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
44 #### Logging management #### |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
45 # If we are in Debug mode, also print in stdout the debug dump |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
46 log = Logger(tool_directory=toolDirectory, debug=debug_mode) |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
47 log.setup_logging() |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
48 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
49 logging.info("#### Apollo User Manager: Start on Apollo instance: %s #### ", apollo_host) |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
50 logging.debug('JSON parameters: %s\n\n', json.dumps(reader.args)) |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
51 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
52 # Set up apollo |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
53 apollo = ApolloInstance(apollo_host, apollo_admin_user, toolDirectory) |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
54 apollo.manageApolloUser(operations_dictionary) |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
55 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
56 logging.info('#### Apollo User Manager: Congratulation! ####\n') |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
57 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
58 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
59 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
60 |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
61 if __name__ == "__main__": |
9945eba268e6
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
yating-l
parents:
diff
changeset
|
62 main(sys.argv) |