diff --git a/MQTT.py b/MQTT.py index 60fca4a..7ee9849 100644 --- a/MQTT.py +++ b/MQTT.py @@ -79,4 +79,4 @@ if __name__ == '__main__': MQTT.start() MQTT.client.loop_forever() except: - time.sleep(15) + time.sleep(30) diff --git a/tool.py b/tool.py index a28008f..01b06ec 100755 --- a/tool.py +++ b/tool.py @@ -8,19 +8,22 @@ mp4_path = '/home/pi/mp4' def push_stream(client): - p = subprocess.Popen(['/bin/bash /home/pi/lot_manager/bash/start_push_stream.sh'], shell=True, + p = subprocess.Popen(['/bin/bash /home/pi/lot_manager/bash/start_push_stream.sh'], + shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() - output = out.decode('utf-8') + output = out.decode('utf-8').strip() client.publish('success', payload=json.dumps(output, ensure_ascii=False), qos=0) def close_stream(client): - p = subprocess.Popen(['/bin/bash /home/pi/lot_manager/bash/stop_push_stream.sh'], shell=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen(['/bin/bash /home/pi/lot_manager/bash/stop_push_stream.sh'], + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) out, err = p.communicate() - output = out.decode('utf-8') + output = out.decode('utf-8').strip() client.publish('success', payload=json.dumps(output, ensure_ascii=False), qos=0) @@ -38,14 +41,17 @@ def exec_sh(msg, client): return p = subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() - output = out.decode('utf-8') + output = out.decode('utf-8').strip() client.publish('success', payload=json.dumps(output, ensure_ascii=False), qos=0) def get_status(client): - p = subprocess.Popen(['supervisorctl status'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen(['supervisorctl status'], + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) out, err = p.communicate() - output = out.decode('utf-8') + output = out.decode('utf-8').strip() client.publish('success', payload=json.dumps(output, ensure_ascii=False), qos=0) @@ -55,14 +61,13 @@ def update(client): stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() - output = out.decode('utf-8') + output = out.decode('utf-8').strip() client.publish('success', payload=json.dumps(output, ensure_ascii=False), qos=0) def get_list_record(): data = { - "data": os.listdir(mp4_path), - "device_name": os.getenv("device_name") + "data": os.listdir(mp4_path) } requests.post("http://shop.lihaink.cn/api/index/file_list", json=data)