This commit is contained in:
xyj 2023-12-27 18:10:39 +08:00
parent b0e63bc5b5
commit 4e5be6bd2e
2 changed files with 124 additions and 124 deletions

View File

@ -6,8 +6,8 @@ subscribe_topic=lihai_lot_walnutpi_dev_1
# 发布消息的主题 # 发布消息的主题
publish_topic=camera_1 publish_topic=camera_1
info_topic=info_dev_1 info_topic=info_dev_1
username=lihai_lot_land_1 username=17378971117
password=lihai_lot_land_1 password=17378971117
#################################### ####################################
# 设备2-32G # 设备2-32G
[lihai_lot_walnutpi_dev_2] [lihai_lot_walnutpi_dev_2]

10
tool.py
View File

@ -60,11 +60,11 @@ def exec_sh(msg, client):
client.publish(info_topic, payload=publish_payload(code=200, msg='reloading'), qos=0) client.publish(info_topic, payload=publish_payload(code=200, msg='reloading'), qos=0)
subprocess.Popen([cmd], shell=True) subprocess.Popen([cmd], shell=True)
return return
# subprocess.Popen([cmd], shell=True) subprocess.Popen([cmd], shell=True)
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').strip() # output = out.decode('utf-8').strip()
client.publish(info_topic, payload=publish_payload(code=200, msg=output), qos=0) # client.publish(info_topic, payload=publish_payload(code=200, msg=output), qos=0)
def get_status(client): def get_status(client):