removed library check since it is now included in the integration #2

This commit is contained in:
tomaae 2019-12-08 09:09:31 +01:00
parent b70bb9db92
commit 4f8c709488
3 changed files with 10 additions and 33 deletions

View file

@ -25,7 +25,6 @@ from .const import (
DEFAULT_SCAN_INTERVAL,
)
from .exceptions import OldLibrouteros
from .mikrotikapi import MikrotikAPI
_LOGGER = logging.getLogger(__name__)
@ -73,16 +72,12 @@ class MikrotikControllerConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "name_exists"
# Test connection
try:
api = MikrotikAPI(host=user_input["host"],
username=user_input["username"],
password=user_input["password"],
port=user_input["port"],
use_ssl=user_input["ssl"]
)
except OldLibrouteros:
errors["base"] = "librouteros_invalid"
else:
if not api.connect():
errors[CONF_HOST] = api.error

View file

@ -1,9 +1,5 @@
"""Exceptions for Mikrotik Router."""
class OldLibrouteros(Exception):
"""Old librouteros version."""
class ApiEntryNotFound(Exception):
"""Old librouteros version."""
"""Api entry not found."""

View file

@ -5,7 +5,7 @@ import logging
import os
import sys
import importlib
from .exceptions import OldLibrouteros, ApiEntryNotFound
from .exceptions import ApiEntryNotFound
MODULE_PATH = os.path.join(os.path.dirname(__file__), "librouteros", "__init__.py")
MODULE_NAME = "librouteros"
@ -38,24 +38,10 @@ class MikrotikAPI:
self._connected = False
self.error = ""
self.check_library()
# Default ports
if not self._port:
self._port = 8729 if self._use_ssl else 8728
# ---------------------------
# check_library
# ---------------------------
def check_library(self):
if not hasattr(librouteros.exceptions, 'ConnectionClosed'):
error = "Invalid librouteros library version installed, possible conflict with other software."
raise OldLibrouteros(error)
if not hasattr(librouteros.exceptions, 'ProtocolError'):
error = "Invalid librouteros library version installed, possible conflict with other software."
raise OldLibrouteros(error)
# ---------------------------
# connect
# ---------------------------