updated exceptions in api for only needed parts

This commit is contained in:
tomaae 2019-12-06 01:30:07 +01:00
parent d991d14a35
commit fc9939aeab

View file

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