Upgrade python-whois to 0.7.2 (#26788)
This commit is contained in:
1 parent
8c580209a6
commit
a9ff15077c
3 files changed
+6
-9
No files matched your search
@@ -3,6 +3,7 @@ from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
import whois
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_NAME
|
||||
@@ -32,8 +33,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the WHOIS sensor."""
|
||||
import whois
|
||||
|
||||
domain = config.get(CONF_DOMAIN)
|
||||
name = config.get(CONF_NAME)
|
||||
|
||||
@@ -41,7 +40,9 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
if "expiration_date" in whois.whois(domain):
|
||||
add_entities([WhoisSensor(name, domain)], True)
|
||||
else:
|
||||
_LOGGER.error("WHOIS lookup for %s didn't contain expiration_date", domain)
|
||||
_LOGGER.error(
|
||||
"WHOIS lookup for %s didn't contain an expiration date", domain
|
||||
)
|
||||
return
|
||||
except whois.BaseException as ex:
|
||||
_LOGGER.error("Exception %s occurred during WHOIS lookup for %s", ex, domain)
|
||||
@@ -53,8 +54,6 @@ class WhoisSensor(Entity):
|
||||
|
||||
def __init__(self, name, domain):
|
||||
"""Initialize the sensor."""
|
||||
import whois
|
||||
|
||||
self.whois = whois.whois
|
||||
|
||||
self._name = name
|
||||
@@ -95,8 +94,6 @@ class WhoisSensor(Entity):
|
||||
|
||||
def update(self):
|
||||
"""Get the current WHOIS data for the domain."""
|
||||
import whois
|
||||
|
||||
try:
|
||||
response = self.whois(self._domain)
|
||||
except whois.BaseException as ex:
|
||||
|
||||
Reference in new issue
Block a user