update
This commit is contained in:
parent
8a7209e7b9
commit
5366686433
2
MQTT.py
2
MQTT.py
|
@ -23,7 +23,7 @@ class MQTT:
|
||||||
client.publish('success', payload='close_stream success', qos=0)
|
client.publish('success', payload='close_stream success', qos=0)
|
||||||
elif data == "exec":
|
elif data == "exec":
|
||||||
# 执行命令
|
# 执行命令
|
||||||
exec_sh(msg)
|
exec_sh(msg, client)
|
||||||
client.publish('success', payload='exec_sh success', qos=0)
|
client.publish('success', payload='exec_sh success', qos=0)
|
||||||
elif data == "update":
|
elif data == "update":
|
||||||
# git更新项目和配置文件
|
# git更新项目和配置文件
|
||||||
|
|
4
tool.py
4
tool.py
|
@ -15,14 +15,14 @@ def close_stream():
|
||||||
subprocess.Popen(['/bin/bash stop_push.sh'], shell=True)
|
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"]
|
cmd = json.loads(msg.payload.decode('utf-8'))["data"]
|
||||||
if cmd == "supervisorctl stop __mqtt__":
|
if cmd == "supervisorctl stop __mqtt__":
|
||||||
return
|
return
|
||||||
p = subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
out, err = p.communicate()
|
out, err = p.communicate()
|
||||||
output = out.decode('utf-8')
|
output = out.decode('utf-8')
|
||||||
print(output)
|
client.publish('success', payload=json.dumps(output, ensure_ascii=False), qos=0)
|
||||||
|
|
||||||
|
|
||||||
def update():
|
def update():
|
||||||
|
|
Loading…
Reference in New Issue