Skip to content

Commit

Permalink
Fix librouteros response error handling (home-assistant#31588)
Browse files Browse the repository at this point in the history
  • Loading branch information
engrbm87 authored Feb 7, 2020
1 parent 37205f9 commit c0eb399
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions homeassistant/components/mikrotik/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def force_dhcp(self):
def get_info(self, param):
"""Return device model name."""
cmd = IDENTITY if param == NAME else INFO
data = list(self.command(MIKROTIK_SERVICES[cmd]))
data = self.command(MIKROTIK_SERVICES[cmd])
return data[0].get(param) if data else None

def get_hub_details(self):
Expand All @@ -148,7 +148,7 @@ def connect_to_hub(self):

def get_list_from_interface(self, interface):
"""Get devices from interface."""
result = list(self.command(MIKROTIK_SERVICES[interface]))
result = self.command(MIKROTIK_SERVICES[interface])
return self.load_mac(result) if result else {}

def restore_device(self, mac):
Expand Down Expand Up @@ -224,7 +224,7 @@ def do_arp_ping(self, ip_address, interface):
"address": ip_address,
}
cmd = "/ping"
data = list(self.command(cmd, params))
data = self.command(cmd, params)
if data is not None:
status = 0
for result in data:
Expand All @@ -242,9 +242,9 @@ def command(self, cmd, params=None):
try:
_LOGGER.info("Running command %s", cmd)
if params:
response = self.api(cmd=cmd, **params)
response = list(self.api(cmd=cmd, **params))
else:
response = self.api(cmd=cmd)
response = list(self.api(cmd=cmd))
except (
librouteros.exceptions.ConnectionClosed,
socket.error,
Expand Down

0 comments on commit c0eb399

Please sign in to comment.