Move imports to top for mailgun (#29480)

pull/29495/head
springstan 2019-12-05 06:14:39 +01:00 committed by Paulus Schoutsen
parent 12e1c695ca
commit 81e4e9e26b
3 changed files with 8 additions and 6 deletions

View File

@ -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"

View File

@ -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,

View File

@ -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)