class QNAPStatsAPI: """Class to interface with the API.""" def __init__(self, config): """Initialize the API wrapper.""" protocol = "https" if config[CONF_SSL] else "http" self._api = QNAPStats( f"{protocol}://{config.get(CONF_HOST)}", config.get(CONF_PORT), config.get(CONF_USERNAME), config.get(CONF_PASSWORD), verify_ssl=config.get(CONF_VERIFY_SSL), timeout=config.get(CONF_TIMEOUT), ) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): """Update API information and store locally.""" try: self.data["system_stats"] = self._api.get_system_stats() self.data["system_health"] = self._api.get_system_health() self.data["smart_drive_health"] = self._api.get_smart_disk_health() self.data["volumes"] = self._api.get_volumes() self.data["bandwidth"] = self._api.get_bandwidth() except: # noqa: E722 pylint: disable=bare-except _LOGGER.exception("Failed to fetch QNAP stats from the NAS")
class QNAPStatsAPI(object): """Class to interface with the API.""" def __init__(self, config): """Initialize the API wrapper.""" from qnapstats import QNAPStats protocol = "https" if config.get(CONF_SSL) else "http" self._api = QNAPStats(protocol + "://" + config.get(CONF_HOST), config.get(CONF_PORT), config.get(CONF_USERNAME), config.get(CONF_PASSWORD)) self.data = {} # pylint: disable=bare-except @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): """Update API information and store locally.""" try: self.data["system_stats"] = self._api.get_system_stats() self.data["system_health"] = self._api.get_system_health() self.data["smart_drive_health"] = self._api.get_smart_disk_health() self.data["volumes"] = self._api.get_volumes() self.data["bandwidth"] = self._api.get_bandwidth() except: _LOGGER.exception("Failed to fetch QNAP stats from the NAS.")
class QNAPStatsAPI: """Class to interface with the API.""" def __init__(self, config): """Initialize the API wrapper.""" from qnapstats import QNAPStats protocol = "https" if config.get(CONF_SSL) else "http" self._api = QNAPStats( '{}://{}'.format(protocol, config.get(CONF_HOST)), config.get(CONF_PORT), config.get(CONF_USERNAME), config.get(CONF_PASSWORD), verify_ssl=config.get(CONF_VERIFY_SSL), timeout=config.get(CONF_TIMEOUT), ) self.data = {} @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): """Update API information and store locally.""" try: self.data["system_stats"] = self._api.get_system_stats() self.data["system_health"] = self._api.get_system_health() self.data["smart_drive_health"] = self._api.get_smart_disk_health() self.data["volumes"] = self._api.get_volumes() self.data["bandwidth"] = self._api.get_bandwidth() except: # noqa: E722 pylint: disable=bare-except _LOGGER.exception("Failed to fetch QNAP stats from the NAS")
class QNAPStatsAPI(object): """Class to interface with the API.""" def __init__(self, config): """Initialize the API wrapper.""" from qnapstats import QNAPStats protocol = "https" if config.get(CONF_SSL) else "http" self._api = QNAPStats( protocol + "://" + config.get(CONF_HOST), config.get(CONF_PORT), config.get(CONF_USERNAME), config.get(CONF_PASSWORD)) self.data = {} # pylint: disable=bare-except @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): """Update API information and store locally.""" try: self.data["system_stats"] = self._api.get_system_stats() self.data["system_health"] = self._api.get_system_health() self.data["smart_drive_health"] = self._api.get_smart_disk_health() self.data["volumes"] = self._api.get_volumes() self.data["bandwidth"] = self._api.get_bandwidth() except: _LOGGER.exception("Failed to fetch QNAP stats from the NAS.")