lot_manager/config.py

22 lines
596 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import configparser
from device import device_name
config = configparser.ConfigParser()
# 读取公共配置
config.read('conf/main/common.conf')
# 域名
broker = config.get("broker", "host")
# 端口这里必须是int类型
port = config.getint("broker", "port")
# 读取设备配置
config.read('conf/device/device.conf')
# 订阅的主题
subscribe_topic = config.get(device_name, "subscribe_topic")
# 发布的主题
publish_topic = config.get(device_name, "publish_topic")
# 用户
username = config.get(device_name, "username")
# 密码
password = config.get(device_name, "password")