Browse Source

增加可以通过参数修改配置文件的路径

v2
lxb 8 months ago
parent
commit
768edbf8fe
  1. 6
      client.py
  2. 6
      server.py

6
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)

6
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)

Loading…
Cancel
Save