CrazeeIvan / python-weather-api

Automatically exported from code.google.com/p/python-weather-api
MIT License
0 stars 0 forks source link

Python3 Error when trying to get weather info #35

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Using python 2 everything works as expected:

$ python
Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pywapi
>>> weather = pywapi.get_weather_from_weather_com('GMXX3828')
>>>

But in python3 I get the following error:

$ python3
Python 3.2.3 (default, Mar  1 2013, 11:53:50)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pywapi
>>> weather = pywapi.get_weather_from_weather_com('GMXX3828')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.2/dist-packages/pywapi.py", line 212, in get_weather_from_weather_com
    tag)[0].firstChild.data
AttributeError: 'NoneType' object has no attribute 'data'
>>>

Anyone got an idea what went wrong? It does not happen for all stations, just 
for a few.
Thanks in advance

Original issue reported on code.google.com by andreask...@gmail.com on 26 Feb 2014 at 3:39

GoogleCodeExporter commented 8 years ago
If you need the output of python2:

$ python
Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pywapi
>>> pywapi.get_weather_from_weather_com('GMXX3828')
{'units': {'distance': u'km', 'speed': u'km/h', 'temperature': u'C', 
'rainfall': u'mm', 'pressure': u'mb'}, 'current_conditions': {'moon_phase': 
{'text': u'Waning Crescent', 'icon': u'28'}, 'last_updated': u'2/28/14 2:45 AM 
CET', 'temperature': u'5', 'dewpoint': u'2', 'text': u'Cloudy', 'uv': {'index': 
u'0', 'text': u'Low'}, 'visibility': u'9.7', 'humidity': u'87', 'station': 
u'Ramstein Ab, RP, GM', 'barometer': {'direction': u'steady', 'reading': 
u'1009.48'}, 'feels_like': u'2', 'wind': {'gust': u'N/A', 'direction': u'240', 
'speed': u'11', 'text': u'WSW'}, 'icon': u'26'}, 'location': {'lat': u'49.44', 
'lon': u'7.77', 'name': u'Kaiserslautern, RP, Germany'}, 'forecasts': 
[{'day_of_week': u'Friday', 'high': u'', 'sunset': u'6:10 PM', 'low': u'2', 
'night': {'brief_text': u'Showers', 'text': u'Showers', 'chance_precip': u'60', 
'humidity': u'96', 'wind': {'gust': u'N/A', 'direction': u'228', 'speed': 
u'14', 'text': u'SW'}, 'icon': u'11'}, 'date': u'Feb 27', 'day': {'brief_text': 
u'', 'text': u'', 'chance_precip': u'0', 'humidity': u'0', 'wind': {'gust': 
u'N/A', 'direction': u'0', 'speed': u'calm', 'text': u'CALM'}, 'icon': u''}, 
'sunrise': u'7:14 AM'}, {'day_of_week': u'Saturday', 'high': u'6', 'sunset': 
u'6:10 PM', 'low': u'0', 'night': {'brief_text': u'Lgt Rain/Fog', 'text': 
u'Light Rain / Fog', 'chance_precip': u'50', 'humidity': u'93', 'wind': 
{'gust': u'N/A', 'direction': u'164', 'speed': u'11', 'text': u'SSE'}, 'icon': 
u'11'}, 'date': u'Feb 28', 'day': {'brief_text': u'Showers', 'text': 
u'Showers', 'chance_precip': u'70', 'humidity': u'86', 'wind': {'gust': u'N/A', 
'direction': u'175', 'speed': u'16', 'text': u'S'}, 'icon': u'11'}, 'sunrise': 
u'7:14 AM'}, {'day_of_week': u'Sunday', 'high': u'7', 'sunset': u'6:10 PM', 
'low': u'0', 'night': {'brief_text': u'Foggy', 'text': u'Foggy', 
'chance_precip': u'10', 'humidity': u'92', 'wind': {'gust': u'N/A', 
'direction': u'238', 'speed': u'4', 'text': u'WSW'}, 'icon': u'20'}, 'date': 
u'Mar 1', 'day': {'brief_text': u'PM Showers', 'text': u'PM Showers', 
'chance_precip': u'40', 'humidity': u'85', 'wind': {'gust': u'N/A', 
'direction': u'206', 'speed': u'11', 'text': u'SSW'}, 'icon': u'39'}, 
'sunrise': u'7:14 AM'}, {'day_of_week': u'Monday', 'high': u'6', 'sunset': 
u'6:10 PM', 'low': u'0', 'night': {'brief_text': u'Rain Late', 'text': u'Light 
Rain Late', 'chance_precip': u'70', 'humidity': u'89', 'wind': {'gust': u'N/A', 
'direction': u'178', 'speed': u'8', 'text': u'S'}, 'icon': u'11'}, 'date': 
u'Mar 2', 'day': {'brief_text': u'AM Fog', 'text': u'AM Fog / PM Clouds', 
'chance_precip': u'20', 'humidity': u'82', 'wind': {'gust': u'N/A', 
'direction': u'214', 'speed': u'11', 'text': u'SW'}, 'icon': u'20'}, 'sunrise': 
u'7:14 AM'}, {'day_of_week': u'Tuesday', 'high': u'6', 'sunset': u'6:10 PM', 
'low': u'1', 'night': {'brief_text': u'R/S Showers', 'text': u'Rain / Snow 
Showers', 'chance_precip': u'40', 'humidity': u'88', 'wind': {'gust': u'N/A', 
'direction': u'232', 'speed': u'11', 'text': u'SW'}, 'icon': u'5'}, 'date': 
u'Mar 3', 'day': {'brief_text': u'Light Rain', 'text': u'Light Rain', 
'chance_precip': u'70', 'humidity': u'83', 'wind': {'gust': u'N/A', 
'direction': u'215', 'speed': u'22', 'text': u'SW'}, 'icon': u'11'}, 'sunrise': 
u'7:14 AM'}]}
>>>

Original comment by andreask...@gmail.com on 28 Feb 2014 at 2:12

GoogleCodeExporter commented 8 years ago
Getting the exact same Error for python2 now. The days before it worked fine 
for python2 while it didn't work for python3...

Original comment by andreask...@gmail.com on 28 Feb 2014 at 3:22

GoogleCodeExporter commented 8 years ago

Original comment by jtas...@gmail.com on 4 Jul 2014 at 4:14