added check for old librouteros version in case of conflict with other extensions #2

This commit is contained in:
tomaae 2019-12-07 20:11:09 +01:00
parent 0580ce8eec
commit 3d90f7c19a
2 changed files with 19 additions and 0 deletions

View file

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