From 37bd93a975d6779856e32c66421d7750011eabbb Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 21 May 2016 14:17:02 -0700 Subject: [PATCH 1/8] Version bump to 0.20 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index d9396188487..068b933707b 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1,7 +1,7 @@ # coding: utf-8 """Constants used by Home Assistant components.""" -__version__ = "0.20.0.dev0" +__version__ = "0.20.0" REQUIRED_PYTHON_VER = (3, 4) PLATFORM_FORMAT = '{}.{}' From a28196df9af8cb01b0bf39be872e5873e9816e3d Mon Sep 17 00:00:00 2001 From: Jan Harkes Date: Sun, 22 May 2016 00:21:19 -0400 Subject: [PATCH 2/8] Version bump to 0.20.1 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 068b933707b..2550c417b63 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1,7 +1,7 @@ # coding: utf-8 """Constants used by Home Assistant components.""" -__version__ = "0.20.0" +__version__ = "0.20.1" REQUIRED_PYTHON_VER = (3, 4) PLATFORM_FORMAT = '{}.{}' From ceb0ec5fa4b0608564a9e3292591177e79abca95 Mon Sep 17 00:00:00 2001 From: Jan Harkes Date: Sat, 21 May 2016 22:35:13 -0400 Subject: [PATCH 3/8] Ignore assertions from python threading when looking for leaked threads. While looking for leaked resources (threads) after shutdown and before restart we in some cases get an assertion in the python threading module where we find a thread marked as running at the python level but it has no associated thread at the C level. --- homeassistant/__main__.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/homeassistant/__main__.py b/homeassistant/__main__.py index 9494c2a02d1..ab83d2aa09a 100644 --- a/homeassistant/__main__.py +++ b/homeassistant/__main__.py @@ -321,10 +321,18 @@ def try_to_restart(): # Count remaining threads, ideally there should only be one non-daemonized # thread left (which is us). Nothing we really do with it, but it might be # useful when debugging shutdown/restart issues. - nthreads = sum(thread.isAlive() and not thread.isDaemon() - for thread in threading.enumerate()) - if nthreads > 1: - sys.stderr.write("Found {} non-daemonic threads.\n".format(nthreads)) + try: + nthreads = sum(thread.isAlive() and not thread.isDaemon() + for thread in threading.enumerate()) + if nthreads > 1: + sys.stderr.write( + "Found {} non-daemonic threads.\n".format(nthreads)) + + # Somehow we sometimes seem to trigger an assertion in the python threading + # module. It seems we find threads that have no associated OS level thread + # which are not marked as stopped at the python level. + except AssertionError: + sys.stderr.write("Failed to count non-daemonic threads.\n") # Send terminate signal to all processes in our process group which # should be any children that have not themselves changed the process From 254463592147c5573f4a67e8b10cc759f97747f9 Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Mon, 23 May 2016 13:08:47 -0700 Subject: [PATCH 4/8] Update issue template to prettify the header. --- .github/ISSUE_TEMPLATE.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 75ee964edd7..c570b548360 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,4 +1,6 @@ -Make sure you run the latest version before reporting an issue. Feature requests should go in the forum: https://community.home-assistant.io/c/feature-requests +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](https://community.home-assistant.io/c/feature-requests) of our community forum: **Home Assistant release (`hass --version`):** From 1327051277e917e028b53603d596de31afffedac Mon Sep 17 00:00:00 2001 From: Jan Harkes Date: Mon, 23 May 2016 23:07:37 -0400 Subject: [PATCH 5/8] Version bump to 0.20.2 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 2550c417b63..72f963a090f 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -1,7 +1,7 @@ # coding: utf-8 """Constants used by Home Assistant components.""" -__version__ = "0.20.1" +__version__ = "0.20.2" REQUIRED_PYTHON_VER = (3, 4) PLATFORM_FORMAT = '{}.{}' From d86a5a1e91856bad832a8219a11a1d2918013a9a Mon Sep 17 00:00:00 2001 From: Jan Harkes Date: Mon, 23 May 2016 23:00:46 -0400 Subject: [PATCH 6/8] Don't even bother trying to kill stray child processes. When we change our process group id we don't get keyboard interrupt signals passed if our parent is a bash script. --- homeassistant/__main__.py | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/homeassistant/__main__.py b/homeassistant/__main__.py index ab83d2aa09a..5dd43e0508a 100644 --- a/homeassistant/__main__.py +++ b/homeassistant/__main__.py @@ -4,7 +4,6 @@ from __future__ import print_function import argparse import os import platform -import signal import subprocess import sys import threading @@ -334,29 +333,6 @@ def try_to_restart(): except AssertionError: sys.stderr.write("Failed to count non-daemonic threads.\n") - # Send terminate signal to all processes in our process group which - # should be any children that have not themselves changed the process - # group id. Don't bother if couldn't even call setpgid. - if hasattr(os, 'setpgid'): - sys.stderr.write("Signalling child processes to terminate...\n") - os.kill(0, signal.SIGTERM) - - # wait for child processes to terminate - try: - while True: - time.sleep(1) - if os.waitpid(0, os.WNOHANG) == (0, 0): - break - except OSError: - pass - - elif os.name == 'nt': - # Maybe one of the following will work, but how do we indicate which - # processes are our children if there is no process group? - # os.kill(0, signal.CTRL_C_EVENT) - # os.kill(0, signal.CTRL_BREAK_EVENT) - pass - # Try to not leave behind open filedescriptors with the emphasis on try. try: max_fd = os.sysconf("SC_OPEN_MAX") @@ -408,13 +384,6 @@ def main(): if args.pid_file: write_pid(args.pid_file) - # Create new process group if we can - if hasattr(os, 'setpgid'): - try: - os.setpgid(0, 0) - except PermissionError: - pass - exit_code = setup_and_run_hass(config_dir, args) if exit_code == RESTART_EXIT_CODE and not args.runner: try_to_restart() From 2e10b4bf672d116e0ad03379043eac3e832a84c5 Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Mon, 23 May 2016 13:48:47 -0700 Subject: [PATCH 7/8] If no departure time is set, use now as the default. If departure time is set but does not have a :, assume its a preformed Unix timestamp and send along as raw input. Assume same for arrival_time. --- homeassistant/components/sensor/google_travel_time.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/homeassistant/components/sensor/google_travel_time.py b/homeassistant/components/sensor/google_travel_time.py index b8513fa9bb6..a2f5e317aec 100644 --- a/homeassistant/components/sensor/google_travel_time.py +++ b/homeassistant/components/sensor/google_travel_time.py @@ -175,9 +175,15 @@ class GoogleTravelTimeSensor(Entity): atime = options_copy.get('arrival_time') if dtime is not None and ':' in dtime: options_copy['departure_time'] = convert_time_to_utc(dtime) + elif dtime is not None: + options_copy['departure_time'] = dtime + else: + options_copy['departure_time'] = 'now' if atime is not None and ':' in atime: options_copy['arrival_time'] = convert_time_to_utc(atime) + elif atime is not None: + options_copy['arrival_time'] = atime self._matrix = self._client.distance_matrix(self._origin, self._destination, From 343625d53916ca3a21eb0828956f225d93dd18c8 Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Mon, 23 May 2016 14:05:12 -0700 Subject: [PATCH 8/8] If we have duration_in_traffic use that as the state, otherwise use duration --- homeassistant/components/sensor/google_travel_time.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/sensor/google_travel_time.py b/homeassistant/components/sensor/google_travel_time.py index a2f5e317aec..c4415cc2cef 100644 --- a/homeassistant/components/sensor/google_travel_time.py +++ b/homeassistant/components/sensor/google_travel_time.py @@ -136,11 +136,12 @@ class GoogleTravelTimeSensor(Entity): @property def state(self): """Return the state of the sensor.""" - try: - res = self._matrix['rows'][0]['elements'][0]['duration']['value'] - return round(res/60) - except KeyError: - return None + _data = self._matrix['rows'][0]['elements'][0] + if 'duration_in_traffic' in _data: + return round(_data['duration_in_traffic']['value']/60) + if 'duration' in _data: + return round(_data['duration']['value']/60) + return None @property def name(self):