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

Fix waze_travel_time component ERROR on startup #20316

Merged
merged 10 commits into from Feb 6, 2019

Conversation

@VirtualL
Copy link
Contributor

VirtualL commented Jan 22, 2019

Description:

Fix the unhandled exception with Waze Travel Time sensor upon startup,
by adding Throttle before update_interval are starting.

Related issue (if applicable):
fixes #16676

Error treated:

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/sensor/waze_travel_time.py", line 74, in <lambda>
    EVENT_HOMEASSISTANT_START, lambda _: sensor.update())
  File "/usr/src/app/homeassistant/components/sensor/waze_travel_time.py", line 204, in update
    routes = params.calc_all_routes_info(real_time=self._realtime)
  File "/usr/local/lib/python3.6/site-packages/WazeRouteCalculator/WazeRouteCalculator.py", line 145, in calc_all_routes_info
    routes = self.get_route(npaths, time_delta)
  File "/usr/local/lib/python3.6/site-packages/WazeRouteCalculator/WazeRouteCalculator.py", line 95, in get_route
    response_json = response.json()
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.6/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.6/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Example entry for configuration.yaml (if applicable):

# Example entry for configuration.yaml
sensor:
  - platform: waze_travel_time
    origin: Montréal, QC
    destination: Québec, QC
    region: 'US'

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated in home-assistant.io

If the code communicates with devices, web services, or third-party tools:
- [ ] New dependencies have been added to the REQUIREMENTS variable (example).

  • New dependencies are only imported inside functions that use them (example).
    - [ ] New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
    - [ ] New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works- Tested on Docker Container 0.85.0 , 0.85.1 , 0.86.0.dev0
Fix waze_travel_time component ERROR on startup
Fix the unhandled exception with Waze Travel Time sensor upon startup,
by adding Throttle before update_interval are starting.
@homeassistant

This comment has been minimized.

Copy link

homeassistant commented Jan 22, 2019

Hi @VirtualL,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@homeassistant homeassistant added cla-signed and removed cla-needed labels Jan 22, 2019

@MartinHjelmare
Copy link
Member

MartinHjelmare left a comment

Revert all the changes. Then add the throttle as decorator with fixed interval.

Show resolved Hide resolved homeassistant/components/sensor/waze_travel_time.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/waze_travel_time.py Outdated
@MartinHjelmare

This comment has been minimized.

Copy link
Member

MartinHjelmare commented Jan 23, 2019

#14527 is unrelated to this fix and has already been fixed. I've updated the description.

Change to Throttle as a decorator to update
Change to Throttle as a decorator to update instead of self.update = Throttle(interval)(self.update)
remove unnecessary code.
@VirtualL

This comment has been minimized.

Copy link
Contributor Author

VirtualL commented Feb 4, 2019

Is there anyone who can help check why not passes the tests?

@MartinHjelmare

This comment has been minimized.

Copy link
Member

MartinHjelmare commented Feb 4, 2019

./homeassistant/components/sensor/waze_travel_time.py:89:17: E128 continuation line under-indented for visual indent
homeassistant.components.sensor.waze_travel_time
homeassistant/components/sensor/waze_travel_time.py:89:0: C0330: Wrong continued indentation (add 1 space).
                incl_filter, excl_filter, realtime):
                ^| (bad-continuation)
homeassistant/components/sensor/waze_travel_time.py:9:0: C0411: standard import "import logging" should be placed before "from homeassistant.util import Throttle" (wrong-import-order)
homeassistant/components/sensor/waze_travel_time.py:11:0: C0411: third party import "import voluptuous as vol" should be placed before "from homeassistant.util import Throttle" (wrong-import-order)
homeassistant/components/sensor/waze_travel_time.py:13:0: C0412: Imports from package homeassistant are not grouped (ungrouped-imports)

The line numbers are marked above, so look at those lines to find the problem.

@MartinHjelmare
Copy link
Member

MartinHjelmare left a comment

Thanks!

@MartinHjelmare MartinHjelmare merged commit 3de21d3 into home-assistant:dev Feb 6, 2019

5 checks passed

Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.2%) to 93.335%
Details

@wafflebot wafflebot bot removed the in progress label Feb 6, 2019

@VirtualL

This comment has been minimized.

Copy link
Contributor Author

VirtualL commented Feb 6, 2019

thank you for the guidance! next time will be much easier 🥇 .

@IIIdefconIII

This comment has been minimized.

Copy link

IIIdefconIII commented Feb 7, 2019

which release contains this fix im on 0.87 now

@MartinHjelmare

This comment has been minimized.

Copy link
Member

MartinHjelmare commented Feb 7, 2019

None yet. I'll tag it with 0.87.1.

@MartinHjelmare MartinHjelmare added this to the 0.87.1 milestone Feb 7, 2019

bachya added a commit to bachya/home-assistant that referenced this pull request Feb 7, 2019

Fix waze_travel_time component ERROR on startup (home-assistant#20316)
* Fix waze_travel_time component ERROR on startup

Fix the unhandled exception with Waze Travel Time sensor upon startup,
by adding Throttle before update_interval are starting.

* add missing whitespace after ','

* fix line too long (80 > 79 characters)

* lint

* fix interval to use const

* Change to Throttle as a decorator to update

Change to Throttle as a decorator to update instead of self.update = Throttle(interval)(self.update)
remove unnecessary code.

* fix  indentations

* Update waze_travel_time.py

* Update waze_travel_time.py

* Update waze_travel_time.py

balloob added a commit that referenced this pull request Feb 10, 2019

Fix waze_travel_time component ERROR on startup (#20316)
* Fix waze_travel_time component ERROR on startup

Fix the unhandled exception with Waze Travel Time sensor upon startup,
by adding Throttle before update_interval are starting.

* add missing whitespace after ','

* fix line too long (80 > 79 characters)

* lint

* fix interval to use const

* Change to Throttle as a decorator to update

Change to Throttle as a decorator to update instead of self.update = Throttle(interval)(self.update)
remove unnecessary code.

* fix  indentations

* Update waze_travel_time.py

* Update waze_travel_time.py

* Update waze_travel_time.py

@balloob balloob referenced this pull request Feb 10, 2019

Merged

0.87.1 #20930

@home-assistant home-assistant locked and limited conversation to collaborators Feb 11, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.