Implement writing openweathermap data to database.
[chrisu/seepark.git] / seeparklib / openweathermap.py
index d350eb6d7eb57bdccba0e2d0bc599c9ff37316b4..626f77ed319f5e80cd6e518de1b36931c0bdd0de 100644 (file)
@@ -9,12 +9,12 @@ def openweathermap_json(apikey, cityid):
     """Returns parsed JSON as returned by openweathermap for the given cityid.
     In case of errors, an OpenWeatherMapError is raised."""
     baseurl = 'http://api.openweathermap.org/data/2.5/weather'
-    query = baseurl + '?units=metric&APPID={}&id={}&lang=de'.format(apikey, cityid)
+    url = baseurl + '?units=metric&APPID={}&id={}&lang=de'.format(apikey, cityid)
     try:
-        response = requests.get(query)
+        response = requests.get(url)
         if response.status_code != 200:
             raise OpenWeatherMapError('Got status code {} ({}).'.format(response.status_code, response.reason))
         else:
-            return response.json()
+            return url, response.json()
     except requests.exceptions.RequestException as error:
         raise OpenWeatherMapError('Request not successful: {}'.format(error))