Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Kane610 committed Oct 6, 2018
1 parent 0b5d0d4 commit 2ddc950
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
14 changes: 13 additions & 1 deletion aiounifi/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import logging

from pprint import pformat

LOGGER = logging.getLogger(__name__)


class APIItems:
"""Base class for a map of API Items."""

Expand All @@ -7,6 +14,8 @@ def __init__(self, raw, request, path, item_cls):
self._item_cls = item_cls
self._items = {}
self.process_raw(raw)
LOGGER.debug(pformat(raw))


async def update(self):
raw = await self._request('get', self._path)
Expand All @@ -26,7 +35,10 @@ def values(self):
return self._items.values()

def __getitem__(self, obj_id):
return self._items[obj_id]
try:
return self._items[obj_id]
except KeyError:
LOGGER.error("Couldn't find key: '{}'".format(obj_id))

def __iter__(self):
return iter(self._items)
1 change: 0 additions & 1 deletion aiounifi/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@ async def request(self, method, path, json=None):
def _raise_on_error(data):
"""Check response for error message."""
if isinstance(data, dict) and data['meta']['rc'] == 'error':
print('raise on error', data['meta']['msg'])
raise_error(data['meta']['msg'])
4 changes: 2 additions & 2 deletions aiounifi/devices.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""UniFi devices are hardware produced by Ubiquiti.
"""UniFi devices are network infrastructure.
Access points, Gateways, Switches.
"""
Expand Down Expand Up @@ -62,7 +62,7 @@ def port_table(self):
async def async_set_port_poe_mode(self, port_idx, mode):
"""Set port poe mode.
Auto, 24v, passthrough, off
Auto, 24v, passthrough, off.
"""
url = 's/{site}/rest/device/' + self.id
data = {
Expand Down

0 comments on commit 2ddc950

Please sign in to comment.