Move imports to top for mailgun (#29480)
parent
12e1c695ca
commit
81e4e9e26b
|
@ -6,13 +6,12 @@ import logging
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.const import CONF_API_KEY, CONF_DOMAIN, CONF_WEBHOOK_ID
|
||||
from homeassistant.helpers import config_entry_flow
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_SANDBOX = "sandbox"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Config flow for Mailgun."""
|
||||
from homeassistant.helpers import config_entry_flow
|
||||
from .const import DOMAIN
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
config_entry_flow.register_webhook_flow(
|
||||
DOMAIN,
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
"""Support for the Mailgun mail notifications."""
|
||||
import logging
|
||||
|
||||
from pymailgunner import (
|
||||
Client,
|
||||
MailgunCredentialsError,
|
||||
MailgunDomainError,
|
||||
MailgunError,
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.notify import (
|
||||
|
@ -58,7 +64,6 @@ class MailgunNotificationService(BaseNotificationService):
|
|||
|
||||
def initialize_client(self):
|
||||
"""Initialize the connection to Mailgun."""
|
||||
from pymailgunner import Client
|
||||
|
||||
self._client = Client(self._api_key, self._domain, self._sandbox)
|
||||
_LOGGER.debug("Mailgun domain: %s", self._client.domain)
|
||||
|
@ -68,7 +73,6 @@ class MailgunNotificationService(BaseNotificationService):
|
|||
|
||||
def connection_is_valid(self):
|
||||
"""Check whether the provided credentials are valid."""
|
||||
from pymailgunner import MailgunCredentialsError, MailgunDomainError
|
||||
|
||||
try:
|
||||
self.initialize_client()
|
||||
|
@ -82,7 +86,6 @@ class MailgunNotificationService(BaseNotificationService):
|
|||
|
||||
def send_message(self, message="", **kwargs):
|
||||
"""Send a mail to the recipient."""
|
||||
from pymailgunner import MailgunError
|
||||
|
||||
subject = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
|
||||
data = kwargs.get(ATTR_DATA)
|
||||
|
|
Loading…
Reference in New Issue