diff --git a/common/tool_cmd.py b/common/tool_cmd.py index 9bfe41bed9872f8d189850517185bd027495b4d1..791e1baabe0689d04fab2f934ab8691359a34756 100644 --- a/common/tool_cmd.py +++ b/common/tool_cmd.py @@ -99,9 +99,10 @@ class ToolCmd: def args_help(self): usage_msg = 'extuner [options]\n' + usage_msg += ' --version Get current version\n' usage_msg += ' --work_path Extuner working path\n' usage_msg += ' --inst_path Extuner installed path\n' - usage_msg += ' --inst_path Output file path, including data, log and report\n' + usage_msg += ' --out_path Output file path, including data, log and report\n' usage_msg += ' --func Running function:\n' usage_msg += ' col collect system info\n' usage_msg += ' ana analyze system info\n' @@ -109,6 +110,8 @@ class ToolCmd: # parrent parent_parser = argparse.ArgumentParser(usage = usage_msg) + parent_parser.add_argument('-v', '--version' , action = 'version', version = self.__get_version(), + help = 'Get current version') parent_parser.add_argument('--work_path' , type = str, default = '.', help = 'Work path for extuner') parent_parser.add_argument('--inst_path' , type = str, default = '.', diff --git a/extuner.py b/extuner.py index 2f900ced26a12bb5a407e4f02fff5437457312e1..53a59f0af07452757f3200b5d4f4a6822b318c4c 100644 --- a/extuner.py +++ b/extuner.py @@ -13,39 +13,59 @@ import time # if __name__=='__main__': def main(): - Timer = { "start": "", "stop": "" } - ret = False args = ToolCmd().args_help() - func = args.func - - - if args.work_path == '': - work_path = '/usr/share/extuner/' - else: - work_path = args.work_path - - if args.inst_path == '': - inst_path = '/usr/share/extuner/' - else: - inst_path = args.inst_path - - out_path = args.out_path + func = args.func + + work_path = args.work_path + inst_path = args.inst_path + out_path = args.out_path - SummaryInfo.init(out_path,work_path, inst_path) + SummaryInfo.init(out_path, work_path, inst_path) Logger().info("Extuner 开始执行") - Timer["start"] = time.strftime("%Y-%m-%d %H:%M:%S") - + if 'col' == func: - #get 功能 - ret = SummaryInfo.get_info() - - if ThreadPool().is_thread_working: + func_col() + elif 'ana' == func: + func_ana() + + + Logger().info("Extuner 执行成功") + + +def func_col(): + timer = { "start": "", "stop": "" } + + timer["start"] = time.strftime("%Y-%m-%d %H:%M:%S") + + ret = SummaryInfo.get_info() + + if ThreadPool().is_thread_working(): ThreadPool().thread_finish() + timer["stop"] = time.strftime("%Y-%m-%d %H:%M:%S") + + if ret: + KyReport().ky_build(timer) + + return ret + +def func_ana(): + timer = { "start": "", "stop": "" } - Timer["stop"] = time.strftime("%Y-%m-%d %H:%M:%S") + timer["start"] = time.strftime("%Y-%m-%d %H:%M:%S") - KyReport().ky_build(Timer) + ret = SummaryInfo.get_info() - Logger().info("Extuner 执行成功") - # Logger().info("结果输出目录为 : {}".format(Config.path_format(os.path.abspath(Config.get_output_path())))) \ No newline at end of file + if ThreadPool().is_thread_working(): + ThreadPool().thread_finish() + + # analyze功能 + #get_global_indicators() + #decide_global_indicators() + + timer["stop"] = time.strftime("%Y-%m-%d %H:%M:%S") + + if ret: + KyReport().ky_build(timer) + + return ret diff --git a/main.py b/main.py index f3f490bda808a427149e0812650b6324e034e637..5a39a4c83062eaa8794e9e2a1a3b0511d3965808 100644 --- a/main.py +++ b/main.py @@ -7,8 +7,7 @@ from common.log import Logger # main function if __name__=='__main__': - main() - # try: - # main() - # except Exception as err: - # Logger().error("Error: {}".format(err)) \ No newline at end of file + try: + main() + except Exception as err: + Logger().error("Error: {}".format(err))