diff --git a/client.py b/client.py index 32438cc..250aff4 100644 --- a/client.py +++ b/client.py @@ -2,6 +2,7 @@ import os import json import time import psutil +import argparse import requests import subprocess @@ -188,8 +189,11 @@ def collect_data(): return result_dict def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--cfg', default='client_config.json', type=str, help='the path of config json.') + args = parser.parse_args() # 加载配置文件 - cfg_path = "client_config.json" + cfg_path = args.cfg global client_cfg with open(cfg_path, 'r') as f: client_cfg = json.load(f) diff --git a/server.py b/server.py index 0b2da57..536b3d5 100644 --- a/server.py +++ b/server.py @@ -1,6 +1,7 @@ from flask import Flask, jsonify, request from flask_cors import CORS import json +import argparse #region 全局 @@ -45,8 +46,11 @@ def init(): data_dict['server_dict'][server_name] = None def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--cfg', default='server_config.json', type=str, help='the path of config json.') + args = parser.parse_args() # 加载配置文件 - cfg_path = "server_config.json" + cfg_path = args.cfg global server_cfg with open(cfg_path, 'r') as f: server_cfg = json.load(f)