mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-06-22 17:03:37 +02:00
updated exceptions in api for only needed parts
This commit is contained in:
parent
d991d14a35
commit
fc9939aeab
1 changed files with 50 additions and 49 deletions
|
@ -127,7 +127,6 @@ class MikrotikAPI:
|
||||||
if not self.connect():
|
if not self.connect():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
|
||||||
response = self.path(path)
|
response = self.path(path)
|
||||||
if response is None:
|
if response is None:
|
||||||
return False
|
return False
|
||||||
|
@ -144,6 +143,7 @@ class MikrotikAPI:
|
||||||
mod_param: mod_value
|
mod_param: mod_value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
response.update(**params)
|
response.update(**params)
|
||||||
except librouteros.exceptions.ConnectionClosed:
|
except librouteros.exceptions.ConnectionClosed:
|
||||||
_LOGGER.error("Mikrotik %s connection closed", self._host)
|
_LOGGER.error("Mikrotik %s connection closed", self._host)
|
||||||
|
@ -170,7 +170,6 @@ class MikrotikAPI:
|
||||||
if not self.connect():
|
if not self.connect():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
|
||||||
response = self.path('/system/script')
|
response = self.path('/system/script')
|
||||||
if response is None:
|
if response is None:
|
||||||
return False
|
return False
|
||||||
|
@ -182,8 +181,8 @@ class MikrotikAPI:
|
||||||
if tmp['name'] != name:
|
if tmp['name'] != name:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
run = response('run', **{'.id': tmp['.id']})
|
run = response('run', **{'.id': tmp['.id']})
|
||||||
tuple(run)
|
|
||||||
except librouteros.exceptions.ConnectionClosed:
|
except librouteros.exceptions.ConnectionClosed:
|
||||||
_LOGGER.error("Mikrotik %s connection closed", self._host)
|
_LOGGER.error("Mikrotik %s connection closed", self._host)
|
||||||
self._connected = False
|
self._connected = False
|
||||||
|
@ -198,4 +197,6 @@ class MikrotikAPI:
|
||||||
_LOGGER.error("Mikrotik %s connection error %s", self._host, api_error)
|
_LOGGER.error("Mikrotik %s connection error %s", self._host, api_error)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
tuple(run)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue