From 53666864334ad5e1b7b7700738cb0196cd99e6c0 Mon Sep 17 00:00:00 2001 From: xyj <10908227994@qq.com> Date: Tue, 5 Dec 2023 09:14:18 +0800 Subject: [PATCH] update --- MQTT.py | 2 +- tool.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MQTT.py b/MQTT.py index d7c532e..2c4ed34 100644 --- a/MQTT.py +++ b/MQTT.py @@ -23,7 +23,7 @@ class MQTT: client.publish('success', payload='close_stream success', qos=0) elif data == "exec": # 执行命令 - exec_sh(msg) + exec_sh(msg, client) client.publish('success', payload='exec_sh success', qos=0) elif data == "update": # git更新项目和配置文件 diff --git a/tool.py b/tool.py index d653ce4..ebf2029 100644 --- a/tool.py +++ b/tool.py @@ -15,14 +15,14 @@ def close_stream(): subprocess.Popen(['/bin/bash stop_push.sh'], shell=True) -def exec_sh(msg): +def exec_sh(msg, client): cmd = json.loads(msg.payload.decode('utf-8'))["data"] if cmd == "supervisorctl stop __mqtt__": return p = subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() output = out.decode('utf-8') - print(output) + client.publish('success', payload=json.dumps(output, ensure_ascii=False), qos=0) def update():