Skip to content

Commit

Permalink
Merge pull request #3 from fredrikbaberg/dev_minimal
Browse files Browse the repository at this point in the history
[WIP] Log error message and reason if API call fails
  • Loading branch information
fuffenz authored Sep 30, 2018
2 parents 679bd1c + 457dc59 commit 3ff5c06
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions sl.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,20 @@ def update(self):
self._data.update()

board = []
for i,traffictype in enumerate(['Metros','Buses','Trains','Trams', 'Ships']):
for idx, value in enumerate(self._data.data['ResponseData'][traffictype]):
direction = value['JourneyDirection'] or 0
displaytime = value['DisplayTime'] or ''
destination = value['Destination'] or ''
linenumber = value['LineNumber'] or ''

if (int(self._data._direction) == 0 or int(direction) == int(self._data._direction)):
if(self._data._lines is None or (linenumber in self._data._lines)):
diff = self.parseDepartureTime(displaytime)
board.append({"line":linenumber,"departure":displaytime,"destination":destination, 'time': diff})
if self._data.data['StatusCode'] != 0:
_LOGGER.error("Status code: {}, {}".format(self._data.data['StatusCode'], self._data.data['Message']))
else:
for i,traffictype in enumerate(['Metros','Buses','Trains','Trams', 'Ships']):
for idx, value in enumerate(self._data.data['ResponseData'][traffictype]):
direction = value['JourneyDirection'] or 0
displaytime = value['DisplayTime'] or ''
destination = value['Destination'] or ''
linenumber = value['LineNumber'] or ''

if (int(self._data._direction) == 0 or int(direction) == int(self._data._direction)):
if(self._data._lines is None or (linenumber in self._data._lines)):
diff = self.parseDepartureTime(displaytime)
board.append({"line":linenumber,"departure":displaytime,"destination":destination, 'time': diff})

self._board = sorted(board, key=lambda k: k['time'])

Expand Down

0 comments on commit 3ff5c06

Please sign in to comment.