def main_process(): print '''\n ----------------------------------------------- you can pass params to define dump :(every param can be ignored) example----$ python GradDump.py example----$ python GradDump.py 1_file_name example----$ python GradDump.py 1_file_name 2_destination_directory example----$ python GradDump.py 1_file_name 2_destination_directory 3_process_name 1. 1_file_name 2. 2_destination_directory 3. 3_process_name NOTE: once you've input a param already, the next time function running will use the latest param you input ----------------------------------------------- ''' argv = sys.argv dump_name = 1 path = 2 process = 3 params = ['', '', '', ''] config_file_path = Res.config_path configs = Fun.get_usable_lines_from_file(config_file_path) for config in configs: data = config.split(Res.config_split) if data[0].startswith(Res.ck_dump_name) and len(data) > 1: params[dump_name] = data[1].strip() elif data[0].startswith(Res.ck_path) and len(data) > 1: params[path] = data[1].strip() elif data[0].startswith(Res.ck_process) and len(data) > 1: params[process] = data[1].strip() if Fun.list_contain_content_on_index( argv, dump_name): # the python file name will take the 0 index in array params[dump_name] = argv[dump_name] Fun.replace_line_in_file( config_file_path, Res.ck_dump_name, Res.assemble_config(Res.ck_dump_name, params[dump_name])) if Fun.list_contain_content_on_index(argv, path): params[path] = argv[path] Fun.replace_line_in_file( config_file_path, Res.ck_path, Res.assemble_config(Res.ck_path, params[path])) if Fun.list_contain_content_on_index(argv, process): params[process] = argv[process] Fun.replace_line_in_file( config_file_path, Res.ck_process, Res.assemble_config(Res.ck_process, params[process])) grab_dump_and_convert(params[dump_name], params[path], params[process])
import sys