diff --git a/.coveragerc b/.coveragerc index 5202822b22f..f19e37d00a1 100644 --- a/.coveragerc +++ b/.coveragerc @@ -84,6 +84,7 @@ omit = homeassistant/components/sensor/glances.py homeassistant/components/sensor/mysensors.py homeassistant/components/sensor/openweathermap.py + homeassistant/components/switch/orvibo.py homeassistant/components/sensor/rest.py homeassistant/components/sensor/rpi_gpio.py homeassistant/components/sensor/sabnzbd.py diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index cbc8ec5a633..4d68227d4d0 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -9,11 +9,12 @@ After bootstrapping you can add your own components or start by calling homeassistant.start_home_assistant(bus) """ -import os -import sys +from collections import defaultdict import logging import logging.handlers -from collections import defaultdict +import os +import shutil +import sys import homeassistant.core as core import homeassistant.util.dt as date_util @@ -25,7 +26,7 @@ import homeassistant.components as core_components import homeassistant.components.group as group from homeassistant.helpers.entity import Entity from homeassistant.const import ( - EVENT_COMPONENT_LOADED, CONF_LATITUDE, CONF_LONGITUDE, + __version__, EVENT_COMPONENT_LOADED, CONF_LATITUDE, CONF_LONGITUDE, CONF_TEMPERATURE_UNIT, CONF_NAME, CONF_TIME_ZONE, CONF_CUSTOMIZE, TEMP_CELCIUS, TEMP_FAHRENHEIT) @@ -168,6 +169,7 @@ def from_config_dict(config, hass=None, config_dir=None, enable_log=True, hass.config.config_dir = config_dir mount_local_lib_path(config_dir) + process_ha_config_upgrade(hass) process_ha_core_config(hass, config.get(core.DOMAIN, {})) if enable_log: @@ -281,6 +283,31 @@ def enable_logging(hass, verbose=False, daemon=False, log_rotate_days=None): 'Unable to setup error log %s (access denied)', err_log_path) +def process_ha_config_upgrade(hass): + """ Upgrade config if necessary. """ + version_path = hass.config.path('.HA_VERSION') + + try: + with open(version_path, 'rt') as inp: + conf_version = inp.readline().strip() + except FileNotFoundError: + # Last version to not have this file + conf_version = '0.7.7' + + if conf_version == __version__: + return + + _LOGGER.info('Upgrading config directory from %s to %s', conf_version, + __version__) + + lib_path = hass.config.path('lib') + if os.path.isdir(lib_path): + shutil.rmtree(lib_path) + + with open(version_path, 'wt') as outp: + outp.write(__version__) + + def process_ha_core_config(hass, config): """ Processes the [homeassistant] section from the config. """ hac = hass.config diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index 01c6c1b6e03..ff5198b7ab1 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -87,7 +87,10 @@ def setup(hass, config): if camera: response = camera.camera_image() - handler.wfile.write(response) + if response is not None: + handler.wfile.write(response) + else: + handler.send_response(HTTP_NOT_FOUND) else: handler.send_response(HTTP_NOT_FOUND) @@ -129,7 +132,8 @@ def setup(hass, config): while True: img_bytes = camera.camera_image() - + if img_bytes is None: + continue headers_str = '\r\n'.join(( 'Content-length: {}'.format(len(img_bytes)), 'Content-type: image/jpeg', diff --git a/homeassistant/components/camera/generic.py b/homeassistant/components/camera/generic.py index 55fa4ec913f..b8be51292bf 100644 --- a/homeassistant/components/camera/generic.py +++ b/homeassistant/components/camera/generic.py @@ -42,11 +42,19 @@ class GenericCamera(Camera): def camera_image(self): """ Return a still image reponse from the camera. """ if self._username and self._password: - response = requests.get( - self._still_image_url, - auth=HTTPBasicAuth(self._username, self._password)) + try: + response = requests.get( + self._still_image_url, + auth=HTTPBasicAuth(self._username, self._password)) + except requests.exceptions.RequestException as error: + _LOGGER.error('Error getting camera image: %s', error) + return None else: - response = requests.get(self._still_image_url) + try: + response = requests.get(self._still_image_url) + except requests.exceptions.RequestException as error: + _LOGGER.error('Error getting camera image: %s', error) + return None return response.content diff --git a/homeassistant/components/frontend/version.py b/homeassistant/components/frontend/version.py index 924e46ae814..1435fe16c5c 100644 --- a/homeassistant/components/frontend/version.py +++ b/homeassistant/components/frontend/version.py @@ -1,2 +1,2 @@ """ DO NOT MODIFY. Auto-generated by build_frontend script """ -VERSION = "75532015507fd544f46081ec0eeb5004" +VERSION = "b75e3c9ebd3de2dae0912a89499127a9" diff --git a/homeassistant/components/frontend/www_static/frontend.html b/homeassistant/components/frontend/www_static/frontend.html index 5ae7ce0b002..5157f4dd5a6 100644 --- a/homeassistant/components/frontend/www_static/frontend.html +++ b/homeassistant/components/frontend/www_static/frontend.html @@ -1,6 +1,6 @@ -