Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
Fixed NoneType sseclient error
Browse files Browse the repository at this point in the history
  • Loading branch information
tchellomello committed Jun 5, 2018
1 parent 05c1c14 commit 0c86667
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions pyarlo/base_station.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,28 @@ def thread_function(self):

self.__sseclient = sseclient.SSEClient(data)

for event in (self.__sseclient).events():
if not self.__subscribed:
break
data = json.loads(event.data)
if data.get('status') == "connected":
_LOGGER.debug("Successfully subscribed this base station")
elif data.get('action'):
action = data.get('action')
resource = data.get('resource')
if action == "logout":
_LOGGER.debug("Logged out by some other entity")
self.__subscribed = False
try:
for event in (self.__sseclient).events():
if not self.__subscribed:
break
elif action == "is" and "subscriptions/" not in resource:
self.__events.append(data)
self.__event_handle.set()
data = json.loads(event.data)
if data.get('status') == "connected":
_LOGGER.debug("Successfully subscribed this base station")
elif data.get('action'):
action = data.get('action')
resource = data.get('resource')
if action == "logout":
_LOGGER.debug("Logged out by some other entity")
self.__subscribed = False
break
elif action == "is" and "subscriptions/" not in resource:
self.__events.append(data)
self.__event_handle.set()

except TypeError as error:
_LOGGER.debug("Got unexpected error: %s", error)
return None

return True

def _get_event_stream(self):
Expand Down

0 comments on commit 0c86667

Please sign in to comment.