update
This commit is contained in:
parent
8db51ceb4d
commit
1b8690bc2e
2
MQTT.py
2
MQTT.py
|
@ -1,4 +1,4 @@
|
||||||
import json
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
|
|
6
tool.py
6
tool.py
|
@ -92,14 +92,18 @@ def reload(client):
|
||||||
|
|
||||||
|
|
||||||
def get_list_record(client):
|
def get_list_record(client):
|
||||||
|
try:
|
||||||
data = {
|
data = {
|
||||||
"data": os.listdir(mp4_path)
|
"data": os.listdir(mp4_path)
|
||||||
}
|
}
|
||||||
r = requests.post(post_record_list_url, json=data)
|
r = requests.post(post_record_list_url, json=data)
|
||||||
client.publish(info_topic, payload=publish_payload(code=200, msg=str(r)), qos=0)
|
client.publish(info_topic, payload=publish_payload(code=200, msg=str(r)), qos=0)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def get_record(msg, client):
|
def get_record(msg, client):
|
||||||
|
try:
|
||||||
filename = json.loads(msg.payload.decode('utf-8'))["data"]
|
filename = json.loads(msg.payload.decode('utf-8'))["data"]
|
||||||
if filename is None or filename == '':
|
if filename is None or filename == '':
|
||||||
client.publish(info_topic, payload=publish_payload(code=404, msg='没有该文件'), qos=0)
|
client.publish(info_topic, payload=publish_payload(code=404, msg='没有该文件'), qos=0)
|
||||||
|
@ -108,3 +112,5 @@ def get_record(msg, client):
|
||||||
files = {filename: open(os.path.join(mp4_path, filename), 'rb'), "Content-Type": "application/octet-stream"}
|
files = {filename: open(os.path.join(mp4_path, filename), 'rb'), "Content-Type": "application/octet-stream"}
|
||||||
r = requests.post(post_record_url, files=files)
|
r = requests.post(post_record_url, files=files)
|
||||||
client.publish(info_topic, payload=publish_payload(code=200, msg=str(r)), qos=0)
|
client.publish(info_topic, payload=publish_payload(code=200, msg=str(r)), qos=0)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
Loading…
Reference in New Issue