From e098cd8d7720c18c384e5b17cbbf780745fba2b1 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Tue, 24 Mar 2015 17:00:35 +0100 Subject: [PATCH] alfred.py: better ask for forgiveness, than permission --- alfred.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/alfred.py b/alfred.py index 3c08b78..ec6a4ca 100644 --- a/alfred.py +++ b/alfred.py @@ -24,11 +24,13 @@ def aliases(): alias = {} for node in nodeinfo(): node_alias = {} - if 'location' in node: - try: - node_alias['gps'] = str(node['location']['latitude']) + ' ' + str(node['location']['longitude']) - except KeyError: - pass + + try: + # TODO: better pass lat, lng as a tuple? + node_alias['gps'] = "{lat}\x20{lng}".format(lat=node['location']['latitude'], + lng=node['location']['longitude']) + except KeyError: + pass try: node_alias['firmware'] = node['software']['firmware']['release']