2023-12-11 16:46:03 +08:00
|
|
|
|
import configparser
|
|
|
|
|
|
2023-12-11 16:51:15 +08:00
|
|
|
|
import subprocess
|
2023-12-11 16:46:03 +08:00
|
|
|
|
|
2023-12-18 10:51:06 +08:00
|
|
|
|
try:
|
|
|
|
|
p = subprocess.Popen(['cat /home/pi/device_name'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
|
out, err = p.communicate()
|
|
|
|
|
# 设备名称,必须要有
|
|
|
|
|
device_name = out.decode('utf-8').strip()
|
2023-12-11 16:51:15 +08:00
|
|
|
|
|
2023-12-18 10:51:06 +08:00
|
|
|
|
# 读取配置
|
|
|
|
|
config = configparser.ConfigParser()
|
|
|
|
|
# 读取公共配置
|
|
|
|
|
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")
|
2023-12-14 11:29:40 +08:00
|
|
|
|
|
2023-12-18 10:51:06 +08:00
|
|
|
|
# 读取设备配置
|
|
|
|
|
config.read('conf/device/device.conf')
|
|
|
|
|
# 订阅的主题
|
|
|
|
|
subscribe_topic = config.get(device_name, "subscribe_topic")
|
|
|
|
|
# 发布数据的主题
|
|
|
|
|
publish_topic = config.get(device_name, "publish_topic")
|
|
|
|
|
# 发布信息的主题
|
|
|
|
|
info_topic = config.get(device_name, "info_topic")
|
|
|
|
|
# 用户
|
|
|
|
|
username = config.get(device_name, "username")
|
|
|
|
|
# 密码
|
|
|
|
|
password = config.get(device_name, "password")
|
2023-12-11 16:51:15 +08:00
|
|
|
|
|
2023-12-18 10:51:06 +08:00
|
|
|
|
# 特殊配置
|
|
|
|
|
config.read('conf/zhanguan/topic.conf')
|
|
|
|
|
zhanguan_device_name = config.get("device", "name")
|
2023-12-14 09:26:35 +08:00
|
|
|
|
|
2023-12-18 10:51:06 +08:00
|
|
|
|
# tool配置
|
|
|
|
|
mp4_path = '/home/pi/mp4'
|
|
|
|
|
except Exception as e:
|
|
|
|
|
# print(e)
|
|
|
|
|
pass
|