update
This commit is contained in:
parent
955cfa3e2a
commit
e6aecf807a
|
@ -3,7 +3,7 @@
|
|||
host=mqtt.lihaink.cn
|
||||
port=1883
|
||||
[record]
|
||||
post_record_list_url=https://shop.lihaink.cn/api/index/file_list
|
||||
post_record_url=https://shop.lihaink.cn/api/index/upload
|
||||
post_record_list_url=https://ceshi-iot.lihaink.cn/api/index/file_list
|
||||
post_record_url=https://ceshi-iot.lihaink.cn/api/index/upload
|
||||
[publish_pwd]
|
||||
value=123456
|
|
@ -3,9 +3,8 @@ import time
|
|||
from api import add
|
||||
from db.base import Base, engine
|
||||
from db.models.lot_data_model import LOT_DATA
|
||||
|
||||
Base.metadata.create_all(bind=engine)
|
||||
try:
|
||||
Base.metadata.create_all(bind=engine)
|
||||
data = {'ambient_temperature': -1,
|
||||
'ambient_humidity': -1,
|
||||
'carbon_dioxide': -1,
|
||||
|
|
|
@ -8,7 +8,8 @@ folder_path = '/home/pi/mp4'
|
|||
size = 20
|
||||
# 检查文件夹大小,如果超过20G,则开始删除文件
|
||||
# 获取当前文件夹的大小
|
||||
while True:
|
||||
try:
|
||||
while True:
|
||||
folder_size = sum(os.path.getsize(f) for f in glob.glob(os.path.join(folder_path, '*')))
|
||||
if folder_size > size * 1024 * 1024 * 1024: # 检查是否超过20G
|
||||
# 获取所有文件的时间戳和文件名
|
||||
|
@ -22,3 +23,5 @@ while True:
|
|||
# print("文件夹小于20G")
|
||||
break
|
||||
time.sleep(2)
|
||||
except:
|
||||
pass
|
||||
|
|
12
tool.py
12
tool.py
|
@ -6,7 +6,14 @@ import requests
|
|||
|
||||
from config import mp4_path, post_record_list_url, post_record_url
|
||||
|
||||
def exception_handler(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
try:
|
||||
return func(*args, **kwargs)
|
||||
except Exception as e:
|
||||
print(f"函数{func.__name__}中发生了异常:{e}")
|
||||
|
||||
return wrapper
|
||||
def push_stream(client):
|
||||
p = subprocess.Popen(['/bin/bash /home/pi/lot_manager/bash/start_push_stream.sh'],
|
||||
shell=True,
|
||||
|
@ -76,7 +83,7 @@ def get_list_record(client):
|
|||
data = {
|
||||
"data": os.listdir(mp4_path)
|
||||
}
|
||||
r = requests.post(post_record_list_url, data=data)
|
||||
r = requests.post(post_record_list_url, json=data)
|
||||
client.publish('success', payload=str(r), qos=0)
|
||||
|
||||
|
||||
|
@ -89,3 +96,6 @@ def get_record(msg, client):
|
|||
files = {filename: open(os.path.join(mp4_path, filename), 'rb'), "Content-Type": "application/octet-stream"}
|
||||
r = requests.post(post_record_url, files=files)
|
||||
client.publish('success', payload=str(r), qos=0)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue