WIP: [weather] correct capitalization in dict
[weather] correct capitalization in dict
The [weather]
module of wetboobs
was failing for me when I tried to retrieve current
:
examples!
wetboobs:/cities> current 1
2018-12-28 07:46:29,005:DEBUG:bcall:1.4:bcall.py:92:backend_process <Backend u'weather'>: Calling function <bound method WetBoobs._do_complete of <weboob.applications.wetboobs.wetboobs.WetBoobs object at 0x105306a50>>
2018-12-28 07:46:29,007:DEBUG:urllib3.connectionpool:1.4:connectionpool.py:240:_get_conn Resetting dropped connection: api.weather.com
2018-12-28 07:46:32,097:DEBUG:urllib3.connectionpool:1.4:connectionpool.py:393:_make_request https://api.weather.com:443 "GET /v2/turbo/vt1currentdatetime;vt1observation?units=m&language=fr-FR&geocode=40.71,-74.01&format=json&apiKey=d522aa97197fd864d36b418f39ebb323 HTTP/1.1" 200 609
2018-12-28 07:46:32,099:DEBUG:backend.weather.browser:1.4:browsers.py:695:internal_callback Handle https://api.weather.com/v2/turbo/vt1currentdatetime;vt1observation?units=m&language=fr-FR&geocode=40.71,-74.01&format=json&apiKey=d522aa97197fd864d36b418f39ebb323 with WeatherPage
2018-12-28 07:46:32,100:WARNING:get_current:1.4:elements.py:335:handle_attr Attribute date (in /path/to/weboob/modules/1.4/weather/pages.py:46) raises ItemNotFound("Element [u'vt1currentdatetime', u'datetime'] not found",)
2018-12-28 07:46:32,100:DEBUG:bcall:1.4:bcall.py:98:backend_process <Backend u'weather'>: Called function <bound method WetBoobs._do_complete of <weboob.applications.wetboobs.wetboobs.WetBoobs object at 0x105306a50>> raised an error: ItemNotFound("Element [u'vt1currentdatetime', u'datetime'] not found",)
Bug(weather): Element [u'vt1currentdatetime', u'datetime'] not found
(If --auto-update is passed on the command-line, new versions of the module will be checked automatically)
Traceback (most recent call last):
File "/path/to/weboob/lib/python2.7/site-packages/weboob-1.4-py2.7.egg/weboob/core/bcall.py", line 94, in backend_process
result = function(backend, *args, **kwargs)
File "/path/to/weboob/lib/python2.7/site-packages/weboob-1.4-py2.7.egg/weboob/tools/application/base.py", line 310, in _do_complete
res = getattr(backend, function)(*args, **kwargs)
File "/path/to/weboob/modules/1.4/weather/module.py", line 42, in get_current
return self.browser.get_current(city_id)
File "/path/to/weboob/modules/1.4/weather/browser.py", line 43, in get_current
return self.weather_page.go(city_id=city_id, api=self.API_KEY).get_current()
File "/path/to/weboob/lib/python2.7/site-packages/weboob-1.4-py2.7.egg/weboob/browser/elements.py", line 55, in inner
return klass(self)(*args, **kwargs)
File "/path/to/weboob/lib/python2.7/site-packages/weboob-1.4-py2.7.egg/weboob/browser/elements.py", line 292, in __call__
for obj in self:
File "/path/to/weboob/lib/python2.7/site-packages/weboob-1.4-py2.7.egg/weboob/browser/elements.py", line 311, in __iter__
self.handle_attr(attr, getattr(self, 'obj_%s' % attr))
File "/path/to/weboob/lib/python2.7/site-packages/weboob-1.4-py2.7.egg/weboob/browser/elements.py", line 328, in handle_attr
value = self.use_selector(func, key=key)
File "/path/to/weboob/lib/python2.7/site-packages/weboob-1.4-py2.7.egg/weboob/browser/elements.py", line 88, in use_selector
value = func(self)
File "/path/to/weboob/lib/python2.7/site-packages/weboob-1.4-py2.7.egg/weboob/browser/filters/base.py", line 184, in __call__
return self.filter(self.select(self.selector, item))
File "/path/to/weboob/lib/python2.7/site-packages/weboob-1.4-py2.7.egg/weboob/browser/filters/base.py", line 168, in select
ret = selector(item)
File "/path/to/weboob/lib/python2.7/site-packages/weboob-1.4-py2.7.egg/weboob/browser/filters/base.py", line 184, in __call__
return self.filter(self.select(self.selector, item))
File "/path/to/weboob/lib/python2.7/site-packages/weboob-1.4-py2.7.egg/weboob/browser/filters/base.py", line 133, in print_debug
res = function(self, value)
File "/path/to/weboob/lib/python2.7/site-packages/weboob-1.4-py2.7.egg/weboob/browser/filters/json.py", line 60, in filter
return self.default_or_raise(ItemNotFound('Element %r not found' % self.selector))
File "/path/to/weboob/lib/python2.7/site-packages/weboob-1.4-py2.7.egg/weboob/browser/filters/base.py", line 71, in default_or_raise
raise exception
ItemNotFound: Element [u'vt1currentdatetime', u'datetime'] not found
Upon examination, there is no datetime
field in the data returned from weather.com. Rather there exists a dateTime
field:
curl -sSL https://api.weather.com/v2/turbo/vt1currentdatetime\;vt1observation\?units\=m\&language\=fr-FR\&geocode\=40.71,-74.01\&format\=json\&apiKey\=d522aa97197fd864d36b418f39ebb323 |jq
{
"id": "40.71,-74.01",
"vt1currentdatetime": {
"dateTime": "2018-12-28T16:52:31.237-05:00",
"tmZnAbbr": "EST"
},
"vt1observation": {
"altimeter": 1012.53,
"barometerTrend": "En baisse",
"barometerCode": 2,
"barometerChange": -1.35,
"dewPoint": 14,
"feelsLike": 14,
"gust": null,
"humidity": 100,
"icon": 11,
"observationTime": "2018-12-28T16:51:07-0500",
"obsQualifierCode": null,
"obsQualifierSeverity": null,
"phrase": "Averses",
"precip24Hour": 16.76,
"snowDepth": 0,
"temperature": 14,
"temperatureMaxSince7am": 14,
"uvIndex": 0,
"uvDescription": "Faible",
"visibility": 4.83,
"windSpeed": 8,
"windDirCompass": "SO",
"windDirDegrees": 230
}
}
This PR adjusts the code to restore this functionality.