feat: 添加新遠程頁面
This commit is contained in:
22
app.py
22
app.py
@@ -23,6 +23,8 @@ processes = []
|
||||
|
||||
time_record = None
|
||||
|
||||
task_run_flag = False
|
||||
|
||||
# 日志队列
|
||||
queue = Queue()
|
||||
# 跳过任务 干预任务调度
|
||||
@@ -54,6 +56,10 @@ fileOptions_list = ['cfg_args.toml','cfg_main.toml', 'cfg_subtask.toml']
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
@app.route('/run')
|
||||
def run():
|
||||
return render_template('index1.html')
|
||||
|
||||
@app.route('/csdn')
|
||||
def csdn():
|
||||
return render_template('csdn.html')
|
||||
@@ -64,6 +70,7 @@ def operate_handle(data):
|
||||
global task_process
|
||||
global processes
|
||||
global time_record
|
||||
global task_run_flag
|
||||
if data['type'] == 'save_config':
|
||||
f = open(os.path.join(fileOptions_path,data['file_name']), 'w')
|
||||
ret = toml.dump(data['content'], f)
|
||||
@@ -99,6 +106,7 @@ def operate_handle(data):
|
||||
elif data['type'] == 'operate_task':
|
||||
# 任务函数
|
||||
if data['content'] == 'run':
|
||||
task_run_flag = True
|
||||
if task_process != None:
|
||||
task_process.terminate()
|
||||
time_record = time.perf_counter()
|
||||
@@ -106,6 +114,7 @@ def operate_handle(data):
|
||||
task_process.start()
|
||||
logger.info("开启 task")
|
||||
elif data['content'] == 'stop':
|
||||
task_run_flag = False
|
||||
task_process.terminate()
|
||||
logger.info(f"任务结束 用时{time.perf_counter() - time_record}s")
|
||||
logger.info("关闭 task")
|
||||
@@ -125,6 +134,12 @@ def operate_handle(data):
|
||||
elif data['type'] == 'skip_task':
|
||||
logger.info(data)
|
||||
skip_task_queue.put(1)
|
||||
elif data['type'] == 'save_target_person':
|
||||
config_path = os.path.join(fileOptions_path, 'cfg_args.toml')
|
||||
config_args = toml.load(config_path)
|
||||
config_args['lane_mode']['mode_index'] = int(data['content'])
|
||||
with open(config_path, 'w') as config_file:
|
||||
toml.dump(config_args, config_file)
|
||||
|
||||
@socketio.on('connect')
|
||||
def test_connect():
|
||||
@@ -134,6 +149,7 @@ def test_connect():
|
||||
for item in fileOptions_list:
|
||||
config_data[item] = toml.load(os.path.join(fileOptions_path,item))
|
||||
socketio.emit('config_data', {'type': 'config_data', 'content': config_data})
|
||||
socketio.emit('task_status', {'type': 'task_status', 'content': int(task_run_flag)})
|
||||
def thread_function():
|
||||
global queue
|
||||
while True:
|
||||
@@ -146,6 +162,12 @@ def thread_function():
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
config_path = os.path.join(fileOptions_path, 'cfg_args.toml')
|
||||
config_args = toml.load(config_path)
|
||||
config_args['lane_mode']['mode_index'] = 1
|
||||
with open(config_path, 'w') as config_file:
|
||||
toml.dump(config_args, config_file)
|
||||
|
||||
log_file = "server_processes.log"
|
||||
log = open(log_file, "w")
|
||||
time.sleep(2)
|
||||
|
||||
Reference in New Issue
Block a user