Skip to content
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

Hotfix 20 2 #2154

Merged
merged 4 commits into from
May 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions homeassistant/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import argparse
import os
import platform
import signal
import subprocess
import sys
import threading
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand Down
17 changes: 12 additions & 5 deletions homeassistant/components/sensor/google_travel_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,12 @@ def __init__(self, name, api_key, origin, destination, options):
@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):
Expand Down Expand Up @@ -175,9 +176,15 @@ def update(self):
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,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/const.py
Original file line number Diff line number Diff line change
@@ -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 = '{}.{}'
Expand Down