From 829f52f658d36c2f8890e950ec0bec42b270d9c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Gru=CC=88ndger?= Date: Sun, 22 May 2016 07:29:12 +0200 Subject: [PATCH] Fix: get country code only if we have a valid position --- ogn/collect/receiver.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ogn/collect/receiver.py b/ogn/collect/receiver.py index e986597..4644948 100644 --- a/ogn/collect/receiver.py +++ b/ogn/collect/receiver.py @@ -100,8 +100,9 @@ def update_receivers(): for receiver in unknown_country_query.all(): location = receiver.location - receiver.country_code = get_country_code(location.latitude, location.longitude) - if receiver.country_code is not None: - logger.info("Updated country_code for {} to {}".format(receiver.name, receiver.country_code)) + if location is not None: + receiver.country_code = get_country_code(location.latitude, location.longitude) + if receiver.country_code is not None: + logger.info("Updated country_code for {} to {}".format(receiver.name, receiver.country_code)) app.session.commit()