8000 yahoo_finance.py errors out in initialization · Issue #9144 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

yahoo_finance.py errors out in initialization #9144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Per4merKC opened this issue Aug 26, 2017 · 4 comments
Closed

yahoo_finance.py errors out in initialization #9144

Per4merKC opened this issue Aug 26, 2017 · 4 comments

Comments

@Per4merKC
Copy link

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version):
Using hassio 0.51.2 (HA 0.52.0 not yet available...)

Python release (python3 --version):

Component/platform:
yahoo_finance

Description of problem:
Getting errors for several days. See traceback

Expected:

Problem-relevant configuration.yaml entries and steps to reproduce:

- platform: yahoo_finance
  symbols:
    - S
    - AAPL
    - GOOGL
  1. No longer works, errors out during initialization

Traceback (if applicable):

2017-08-26 10:01:16 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform yahoo_finance
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 352, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 244, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/yahoo_finance.py", line 52, in setup_platform
    data = YahooFinanceData(symbol)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/yahoo_finance.py", line 119, in __init__
    self.stock = Share(self._symbol)
  File "/usr/lib/python3.6/site-packages/yahoo_finance/__init__.py", line 178, in __init__
    self.refresh()
  File "/usr/lib/python3.6/site-packages/yahoo_finance/__init__.py", line 142, in refresh
    self.data_set = self._fetch()
  File "/usr/lib/python3.6/site-packages/yahoo_finance/__init__.py", line 181, in _fetch
    data = super(Share, self)._fetch()
  File "/usr/lib/python3.6/site-packages/yahoo_finance/__init__.py", line 134, in _fetch
    data = self._request(query)
  File "/usr/lib/python3.6/site-packages/yahoo_finance/__init__.py", line 118, in _request
    response = yql.YQLQuery().execute(query)
  File "/usr/lib/python3.6/site-packages/yahoo_finance/yql.py", line 61, in execute
    'env': DATATABLES_URL
  File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

Additional info:

@cogneato
Copy link

Added the component (also Hass.io .51.2) and can confirm the same error.

@fabaff
Copy link
Member
fabaff commented Aug 26, 2017

Seems to be an issue with the module we use:

$ python3
>>> from yahoo_finance import Share
>>> yahoo = Share('YHOO')
[...]
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

@Per4merKC
Copy link
Author
Per4merKC commented Nov 4, 2017

The errors are back!

2017-11-03 22:17:05 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform yahoo_finance
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/yahoo_finance/__init__.py", line 120, in _request
    _, results = response['query']['results'].popitem()
AttributeError: 'NoneType' object has no attribute 'popitem'

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/yahoo_finance/__init__.py", line 123, in _request
    raise YQLQueryError(response['error']['description'])
KeyError: 'error'

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 170, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 352, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 244, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/yahoo_finance.py", line 49, in setup_platform
    if Share(symbol).get_price() is None:
  File "/usr/lib/python3.6/site-packages/yahoo_finance/__init__.py", line 178, in __init__
    self.refresh()
  File "/usr/lib/python3.6/site-packages/yahoo_finance/__init__.py", line 142, in refresh
    self.data_set = self._fetch()
  File "/usr/lib/python3.6/site-packages/yahoo_finance/__init__.py", line 181, in _fetch
    data = super(Share, self)._fetch()
  File "/usr/lib/python3.6/site-packages/yahoo_finance/__init__.py", line 134, in _fetch
    data = self._request(query)
  File "/usr/lib/python3.6/site-packages/yahoo_finance/__init__.py", line 125, in _request
    raise YQLResponseMalformedError()
yahoo_finance.YQLResponseMalformedError: Response malformed.

EDIT

It appears that there is a notice on the Yahoo Finance site indicating that the terms of service are in violation.
Yahoo Finance Issue #140

@fabaff fabaff mentioned this issue Nov 30, 2017
6 tasks
@fabaff
Copy link
Member
fabaff commented Dec 10, 2017

#10873 is a replacement.

@fabaff fabaff closed this as completed Dec 10, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Mar 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants
0