mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-13 19:04:30 +02:00
added check for old librouteros version in case of conflict with other extensions #2
This commit is contained in:
parent
0580ce8eec
commit
3d90f7c19a
2 changed files with 19 additions and 0 deletions
4
custom_components/mikrotik_router/exceptions.py
Normal file
4
custom_components/mikrotik_router/exceptions.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
"""Exceptions for Mikrotik Router."""
|
||||||
|
|
||||||
|
class OldLibrouteros(Exception):
|
||||||
|
"""Old librouteros version."""
|
|
@ -3,6 +3,7 @@
|
||||||
import ssl
|
import ssl
|
||||||
import logging
|
import logging
|
||||||
import librouteros
|
import librouteros
|
||||||
|
from .exceptions import OldLibrouteros
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,10 +28,24 @@ class MikrotikAPI:
|
||||||
self._connected = False
|
self._connected = False
|
||||||
self.error = ""
|
self.error = ""
|
||||||
|
|
||||||
|
self.check_library()
|
||||||
|
|
||||||
# Default ports
|
# Default ports
|
||||||
if not self._port:
|
if not self._port:
|
||||||
self._port = 8729 if self._use_ssl else 8728
|
self._port = 8729 if self._use_ssl else 8728
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# check_library
|
||||||
|
# ---------------------------
|
||||||
|
def check_library(self):
|
||||||
|
if not hasattr(librouteros.exceptions, 'ConnectionClosed'):
|
||||||
|
error = "Old librouteros installed, check for possible conflicts with other integrations."
|
||||||
|
raise OldLibrouteros(error)
|
||||||
|
|
||||||
|
if not hasattr(librouteros.exceptions, 'ProtocolError'):
|
||||||
|
error = "Old librouteros installed, check for possible conflicts with other integrations."
|
||||||
|
raise OldLibrouteros(error)
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# connect
|
# connect
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue