mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-04 06:24:32 +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
|
@ -3,6 +3,7 @@
|
|||
import ssl
|
||||
import logging
|
||||
import librouteros
|
||||
from .exceptions import OldLibrouteros
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -27,10 +28,24 @@ 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 = "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
|
||||
# ---------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue