marians / openweather

Rudimentary python client for OpenWeatherMap.org
9 stars 4 forks source link

ow.get_historic_weather #4

Open kaklik opened 10 years ago

kaklik commented 10 years ago

I am getting error if I try to obtain historical data.

import openweather from datetime import datetime ow = openweather.OpenWeather() print ow.get_weather(61457)

This code works and give me current weather values. But I can not obtain historical data:

start_date = datetime(2014, 5, 20) end_date = datetime(2014, 5, 22) print ow.get_historic_weather(61457, start_date, end_date)

OpenWeather.do_request() got ValueError: No JSON object could be decoded (1. attempt) OpenWeather.do_request() got ValueError: No JSON object could be decoded (2. attempt)

None

OpenWeather.do_request() got ValueError: No JSON object could be decoded (3. attempt)

marians commented 10 years ago

Thanks for your report! Actually I am experiencing the same issues but haven't found the time to investigate the casue yet. Will post updates here.

kaklik commented 10 years ago

OK, similar problem is with stations = ow.find_stations_near( 14.45, # longitude 50.07, # latitude 100 # kilometer radius )

It gives me an empty list.. print stations {u'list': [], u'message': u'', u'calctime': u'', u'cod': u'200', u'cnt': 0}

marians commented 10 years ago

Here is what I get:

$ openweather -v -s 4885 -d 20131001
Requesting http://openweathermap.org/data/2.1/history/station/4885?type=hour&start=1380578400&end=1380664800
OpenWeather.do_request() got ValueError: No JSON object could be decoded (1. attempt)
Requesting http://openweathermap.org/data/2.1/history/station/4885?type=hour&start=1380578400&end=1380664800
OpenWeather.do_request() got ValueError: No JSON object could be decoded (2. attempt)
Requesting http://openweathermap.org/data/2.1/history/station/4885?type=hour&start=1380578400&end=1380664800
OpenWeather.do_request() got ValueError: No JSON object could be decoded (3. attempt)
null

When I curl http://openweathermap.org/data/2.1/history/station/4885?type=hour&start=1380578400&end=1380664800, the servers responds with these headers and no body:

HTTP/1.1 512 
Server: nginx/1.6.0
Date: Fri, 23 May 2014 09:42:48 GMT
Content-Type: application/octet-stream
Content-Length: 0
Connection: keep-alive

Maybe OpenWeatherMap discontinued API version 2.1?

marians commented 10 years ago

Sorry, accidentally hit "Close & Comment".

marians commented 10 years ago

Approached OpenWeatherMap via twitter. https://twitter.com/MarianSteinbach/status/469777143980101632