12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import os
- import uuid
- import socket
- from app.app_config import SPEAKER_CONFIG_FILE, LINPHONE_CONFIG_FILE, PROJECT_CONFIG
- from app import project_cf
- from app import speaker_cf
- from app import linphone_cf
- class Config(object):
- def __init__(self):
- speaker_cf.read(SPEAKER_CONFIG_FILE)
- linphone_cf.read(LINPHONE_CONFIG_FILE)
- project_cf.read(PROJECT_CONFIG)
- #设置型号
- self.model = speaker_cf.get("system", "model")
- #系统主机名
- self.hostname = socket.getfqdn(socket.gethostname())
- #系统ip地址
- self.ipaddr = self._get_host_ip()
- #系统硬件音量
- self.hard_volume = int(speaker_cf.get("system", "volume_out"))
- #系统强控开关
- self.hard_volume_control = speaker_cf.get("volume", "hard_volume_control")
- #系统分机号
- self.exten = linphone_cf.get("auth_info_0", "username")
- #系统分机密码
- self.exten_password = linphone_cf.get("auth_info_0", "passwd")
- #广播系统服务器地址
- self.server_ipaddr = linphone_cf.get("proxy_0", "reg_identity").split("@", 1)[1].lstrip().rstrip()
- #播放器初始化音量
- self.player_current_volume = int(project_cf.get("general", "player_init_volume"))
- #播放器初始化状态
- self.init_player_state = int(project_cf.get("general", "init_player_state"))
- #播放源j
- self.current_uri = project_cf.get("general", "current_uri")
- #设置mac
- self.mac = self._get_mac_address()
- """
- desc:
- 获取设备mac地址
- """
- def _get_mac_address(self):
- mac=uuid.UUID(int = uuid.getnode()).hex[-12:]
- return ":".join([mac[e:e+2] for e in range(0,11,2)]).replace(":", "").lower()
- """
- desc:
- 获取设置出局ip地址
- """
- def _get_host_ip(self):
- try:
- s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
- s.connect(('8.8.8.8',80))
- ip=s.getsockname()[0]
- finally:
- s.close()
- return ip
|