Update and rename local.py to info.py

This commit is contained in:
Pascal Vizeli 2018-04-26 09:44:49 +02:00 committed by GitHub
parent e37ffd6107
commit 2c0a68bd8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,7 @@ _LOGGER = logging.getLogger(__name__)
UNKNOWN = 'Unknown'
class LocalCenter(CoreSysAttributes):
class InfoCenter(CoreSysAttributes):
"""Handle local system information controls."""
def __init__(self, coresys):
@ -42,7 +42,7 @@ class LocalCenter(CoreSysAttributes):
"""Return local CPE."""
return self._data.get('OperatingSystemCPEName', UNKNOWN)
def _check_dbus(self):
def _check_dbus_hostname(self):
"""Check if systemd is connect or raise error."""
if not self.sys_dbus.hostname.is_connected:
_LOGGER.error("No hostname dbus connection available")
@ -50,18 +50,10 @@ class LocalCenter(CoreSysAttributes):
async def update(self):
"""Update properties over dbus."""
self._check_dbus()
self._check_dbus_hostname()
_LOGGER.info("Update local host information")
try:
self._data = await self.sys_dbus.hostname.get_properties()
except HassioError:
_LOGGER.warning("Can't update host system information!")
async def set_hostname(self, hostname):
"""Set local a new Hostname."""
self._check_dbus()
_LOGGER.info("Set Hostname %s", hostname)
await self.sys_dbus.hostname.set_hostname(hostname)
await self.update()