From b3dbda615742c568ac8bfa98e37da74a42fa9f40 Mon Sep 17 00:00:00 2001 From: lxb <1580622474@qq.com> Date: Thu, 5 Dec 2024 20:09:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=AF=E4=BB=A5=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E5=8F=82=E6=95=B0=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client.py | 6 +++++- server.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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)