Mercurial > repos > yating-l > gonramp_apollo_tools
changeset 1:78af01d73add draft
planemo upload for repository https://github.com/Yating-L/suite_gonramp_apollo.git commit 9009fa8663038d2cb4a1c5130600a51f31f654a1-dirty
author | yating-l |
---|---|
date | Tue, 28 Nov 2017 12:43:22 -0500 |
parents | 1da8b9042af4 |
children | 4be6fcac4bf2 |
files | apollo/ApolloInstance.py apollo/ApolloUser.py apolloUserManager.py apolloUserManager.xml logging.json test-data/adduserstogroup.csv util/Logger.py |
diffstat | 7 files changed, 28 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/apollo/ApolloInstance.py Mon Nov 27 14:47:03 2017 -0500 +++ b/apollo/ApolloInstance.py Tue Nov 28 12:43:22 2017 -0500 @@ -74,7 +74,7 @@ apollo_user.deleteApolloUser() elif operation == "add": apollo_user.addApolloUserToGroup() - elif operation == "delete": + elif operation == "remove": apollo_user.removeApolloUserFromeGroup()
--- a/apollo/ApolloUser.py Mon Nov 27 14:47:03 2017 -0500 +++ b/apollo/ApolloUser.py Tue Nov 28 12:43:22 2017 -0500 @@ -45,16 +45,16 @@ self.logger.error("The %s format is not supported!", file_format) with open(filename, 'r') as f: lines = f.readlines() - headers = lines[0].rstrip().split(delimiter) + headers = lines[0].split(delimiter) users = [] lines = lines[1:] for l in lines: - print l l = l.split(delimiter) info = dict() fields = len(l) for i in range(fields): - info[headers[i]] = l[i] + title = headers[i].rstrip() + info[title] = l[i].rstrip() users.append(info) return users @@ -93,6 +93,6 @@ self.logger.error("Cannot find useremail in the text file, make sure you use the correct header, see README file for examples.") if not 'group' in u: self.logger.error("Cannot find group in the text file, make sure you use the correct header, see README file for examples.") - subtools.arrow_add_to_group(u['group'], u['useremail']) + subtools.arrow_remove_from_group(u['group'], u['useremail'])
--- a/apolloUserManager.py Mon Nov 27 14:47:03 2017 -0500 +++ b/apolloUserManager.py Tue Nov 28 12:43:22 2017 -0500 @@ -30,20 +30,16 @@ apollo_host = "http://localhost:"+ apollo_port + "/apollo" apollo_admin_user = reader.getAdminUser() toolDirectory = reader.getToolDir() + extra_files_path = reader.getExtFilesPath() debug_mode = reader.getDebugMode() - operations_dictionary = reader.getOperationList() - #OPERATIONS = ['create', 'delete', 'add', 'remove'] - #create_user_list = reader.getOperationList("create") - #delete_user_list = reader.getOperationList("delete") - #remove_user_list = reader.getOperationList("remove") - #add_user_list = reader.getOperationList("add") + #### Logging management #### # If we are in Debug mode, also print in stdout the debug dump - log = Logger(tool_directory=toolDirectory, debug=debug_mode) + log = Logger(tool_directory=toolDirectory, debug=debug_mode, extra_files_path=extra_files_path) log.setup_logging() logging.info("#### Apollo User Manager: Start on Apollo instance: %s #### ", apollo_host) @@ -54,9 +50,8 @@ apollo.manageApolloUser(operations_dictionary) logging.info('#### Apollo User Manager: Congratulation! ####\n') - - + if __name__ == "__main__": main(sys.argv) \ No newline at end of file
--- a/apolloUserManager.xml Mon Nov 27 14:47:03 2017 -0500 +++ b/apolloUserManager.xml Tue Nov 28 12:43:22 2017 -0500 @@ -14,7 +14,7 @@ </stdio> <command detect_errors="exit_code"><![CDATA[ - + mkdir -p $output.extra_files_path; ## Dump the tool parameters into a JSON file python $json_file parameters.json; python $__tool_directory__/apolloUserManager.py --data_json parameters.json -o $output @@ -92,6 +92,7 @@ #set apollo_admin = {"user_email": str($admin_username), "password": str($admin_password)} #silent $data_parameter_dict.update({"apollo_admin": $apollo_admin}) #silent $data_parameter_dict.update({"tool_directory": str($__tool_directory__)}) +#silent $data_parameter_dict.update({"extra_files_path": str($output.extra_files_path)}) #silent $data_parameter_dict.update({"port": str($advanced_options.port)}) #silent $data_parameter_dict.update({"debug_mode": str($advanced_options.debug_mode)}) with open(file_path, 'w') as f: @@ -236,7 +237,7 @@ </conditional> </inputs> <outputs> - <data format="html" name="output" label="${tool.name}" /> + <data format="txt" name="output" label="${tool.name} on ${on_string}" /> </outputs> <help>
--- a/logging.json Mon Nov 27 14:47:03 2017 -0500 +++ b/logging.json Tue Nov 28 12:43:22 2017 -0500 @@ -20,6 +20,16 @@ "level": "ERROR", "formatter": "simple", "stream": "ext://sys.stderr" + }, + + "debug_file_handler": { + "class": "logging.handlers.RotatingFileHandler", + "level": "DEBUG", + "formatter": "simple", + "filename": "__main__.log", + "maxBytes": 10485760, + "backupCount": 20, + "encoding": "utf8" } }, @@ -33,6 +43,6 @@ "root": { "level": "DEBUG", - "handlers": ["console", "console_stderr"] + "handlers": ["console", "console_stderr", "debug_file_handler"] } } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/adduserstogroup.csv Tue Nov 28 12:43:22 2017 -0500 @@ -0,0 +1,4 @@ +useremail,group +test1@apollo.com,Test A +test2@apollo.com,Test A +test3@apollo.com,Test B \ No newline at end of file
--- a/util/Logger.py Mon Nov 27 14:47:03 2017 -0500 +++ b/util/Logger.py Tue Nov 28 12:43:22 2017 -0500 @@ -32,6 +32,7 @@ config["handlers"][i]["filename"] = os.path.join(self.extra_files_path, config["handlers"][i]["filename"]) logging.config.dictConfig(config) else: + logging.config.dictConfig(config) logging.warn("Extra files path is not set. The log files will exist at current working directory instead of final output folder") else: logging.basicConfig(level=default_level)