diff --git a/config.py b/config.py index e9b4e85..5462c12 100644 --- a/config.py +++ b/config.py @@ -15,6 +15,9 @@ config.read('conf/main/common.conf') broker = config.get("broker", "host") # 端口,这里必须是int类型 port = config.getint("broker", "port") +# 录像地址 +post_record_list_url = config.get("record", "post_record_list_url") +post_record_url = config.get("record", "post_record_url") # 读取设备配置 config.read('conf/device/device.conf') @@ -27,7 +30,8 @@ username = config.get(device_name, "username") # 密码 password = config.get(device_name, "password") - # 特殊配置 config.read('conf/zhanguan/topic.conf') zhanguan_device_name = config.get("device", "name") +# tool配置 +mp4_path = '/home/pi/mp4' \ No newline at end of file diff --git a/tool.py b/tool.py index 40278e6..37413e8 100755 --- a/tool.py +++ b/tool.py @@ -1,13 +1,10 @@ -import configparser import json import os import subprocess import requests -mp4_path = '/home/pi/mp4' -config = configparser.ConfigParser() -config.read('/home/pi/lot_manager/conf/main/common.conf') +from config import mp4_path, post_record_list_url, post_record_url def push_stream(client): @@ -72,7 +69,6 @@ def get_list_record(): data = { "data": os.listdir(mp4_path) } - post_record_list_url = config.get("record", "post_record_list_url") requests.post(post_record_list_url, json=data) @@ -81,6 +77,6 @@ def get_record(msg, client): if filename is None or filename == '': client.publish('error', payload='没有该文件', qos=0) return - post_record_url = config.get("record", "post_record_url") + files = {filename: open(os.path.join(mp4_path, filename), 'rb'), "Content-Type": "application/octet-stream"} requests.post(post_record_url, files=files)