mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-06-22 08:53:32 +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():
|
||||
return None
|
||||
|
||||
try:
|
||||
response = self.path(path)
|
||||
if response is None:
|
||||
return False
|
||||
|
@ -144,6 +143,7 @@ class MikrotikAPI:
|
|||
mod_param: mod_value
|
||||
}
|
||||
|
||||
try:
|
||||
response.update(**params)
|
||||
except librouteros.exceptions.ConnectionClosed:
|
||||
_LOGGER.error("Mikrotik %s connection closed", self._host)
|
||||
|
@ -170,7 +170,6 @@ class MikrotikAPI:
|
|||
if not self.connect():
|
||||
return None
|
||||
|
||||
try:
|
||||
response = self.path('/system/script')
|
||||
if response is None:
|
||||
return False
|
||||
|
@ -182,8 +181,8 @@ class MikrotikAPI:
|
|||
if tmp['name'] != name:
|
||||
continue
|
||||
|
||||
try:
|
||||
run = response('run', **{'.id': tmp['.id']})
|
||||
tuple(run)
|
||||
except librouteros.exceptions.ConnectionClosed:
|
||||
_LOGGER.error("Mikrotik %s connection closed", self._host)
|
||||
self._connected = False
|
||||
|
@ -198,4 +197,6 @@ class MikrotikAPI:
|
|||
_LOGGER.error("Mikrotik %s connection error %s", self._host, api_error)
|
||||
return None
|
||||
|
||||
tuple(run)
|
||||
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue