~ralsina/ubuntu-rest-scopes/add-missing-lat-long

« back to all changes in this revision

Viewing changes to src/scopes/weatherchannel.py

  • Committer: Tarmac
  • Author(s): Roberto Alsina
  • Date: 2016-03-11 14:58:26 UTC
  • mfrom: (509.1.1 ubuntu-rest-scopes)
  • Revision ID: tarmac-20160311145826-2c0l6dbw7q9g2zsa
[r=facundo] Handle TWC returning that there is no location in a given lat/long.

Show diffs side-by-side

added added

removed removed

Lines of Context:
452
452
            loc_result = json.loads(resp.decode('utf-8'))
453
453
        except ValueError as exc:
454
454
            raise BackendDataError(exc, loc_uri)
455
 
        location = loc_result.get('addresses')[0]
 
455
        location = loc_result.get('addresses', [])
 
456
        if location:
 
457
            location = location[0]
 
458
        else:
 
459
            location = {}
456
460
        return location
457
461
 
458
462
    def search_locations(self, query):