From d2b5f429fea6f0e423e6333116ada0cc315cb6c1 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 4 Aug 2015 16:21:09 -0400 Subject: [PATCH] Remove deprecated code --- homeassistant/__init__.py | 12 +++--- homeassistant/bootstrap.py | 15 ++++--- homeassistant/components/group.py | 4 -- homeassistant/components/process.py | 52 ----------------------- homeassistant/helpers/__init__.py | 4 -- homeassistant/helpers/device.py | 10 ----- homeassistant/helpers/device_component.py | 10 ----- homeassistant/util/__init__.py | 6 +-- tests/components/test_group.py | 3 +- 9 files changed, 17 insertions(+), 99 deletions(-) delete mode 100644 homeassistant/components/process.py delete mode 100644 homeassistant/helpers/device.py delete mode 100644 homeassistant/helpers/device_component.py diff --git a/homeassistant/__init__.py b/homeassistant/__init__.py index f5129fd1c95..bf21dc0a15d 100644 --- a/homeassistant/__init__.py +++ b/homeassistant/__init__.py @@ -96,7 +96,7 @@ class HomeAssistant(object): self.pool.stop() def track_point_in_time(self, action, point_in_time): - """Deprecated method to track point in time.""" + """Deprecated method as of 8/4/2015 to track point in time.""" _LOGGER.warning( 'hass.track_point_in_time is deprecated. ' 'Please use homeassistant.helpers.event.track_point_in_time') @@ -104,7 +104,7 @@ class HomeAssistant(object): helper.track_point_in_time(self, action, point_in_time) def track_point_in_utc_time(self, action, point_in_time): - """Deprecated method to track point in UTC time.""" + """Deprecated method as of 8/4/2015 to track point in UTC time.""" _LOGGER.warning( 'hass.track_point_in_utc_time is deprecated. ' 'Please use homeassistant.helpers.event.track_point_in_utc_time') @@ -114,7 +114,7 @@ class HomeAssistant(object): def track_utc_time_change(self, action, year=None, month=None, day=None, hour=None, minute=None, second=None): - """Deprecated method to track UTC time change.""" + """Deprecated method as of 8/4/2015 to track UTC time change.""" # pylint: disable=too-many-arguments _LOGGER.warning( 'hass.track_utc_time_change is deprecated. ' @@ -126,7 +126,7 @@ class HomeAssistant(object): def track_time_change(self, action, year=None, month=None, day=None, hour=None, minute=None, second=None, utc=False): - """Deprecated method to track time change.""" + """Deprecated method as of 8/4/2015 to track time change.""" # pylint: disable=too-many-arguments _LOGGER.warning( 'hass.track_time_change is deprecated. ' @@ -183,7 +183,7 @@ class Event(object): self.event_type = event_type self.data = data or {} self.origin = origin - self.time_fired = util.strip_microseconds( + self.time_fired = date_util.strip_microseconds( time_fired or date_util.utcnow()) def as_dict(self): @@ -502,7 +502,7 @@ class StateMachine(object): def track_change(self, entity_ids, action, from_state=None, to_state=None): """ - DEPRECATED + DEPRECATED AS OF 8/4/2015 """ _LOGGER.warning( 'hass.states.track_change is deprecated. ' diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index 663ed611de4..514c1adce57 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -63,12 +63,15 @@ def setup_component(hass, domain, config=None): def _handle_requirements(component, name): """ Installs requirements for component. """ - if hasattr(component, 'REQUIREMENTS'): - for req in component.REQUIREMENTS: - if not pkg_util.install_package(req): - _LOGGER.error('Not initializing %s because could not install ' - 'dependency %s', name, req) - return False + if not hasattr(component, 'REQUIREMENTS'): + return True + + for req in component.REQUIREMENTS: + if not pkg_util.install_package(req): + _LOGGER.error('Not initializing %s because could not install ' + 'dependency %s', name, req) + return False + return True diff --git a/homeassistant/components/group.py b/homeassistant/components/group.py index ac5e8cd4116..7c24c505add 100644 --- a/homeassistant/components/group.py +++ b/homeassistant/components/group.py @@ -103,10 +103,6 @@ def get_entity_ids(hass, entity_id, domain_filter=None): def setup(hass, config): """ Sets up all groups found definded in the configuration. """ for name, entity_ids in config.get(DOMAIN, {}).items(): - # Support old deprecated method - 2/28/2015 - if isinstance(entity_ids, str): - entity_ids = entity_ids.split(",") - setup_group(hass, name, entity_ids) return True diff --git a/homeassistant/components/process.py b/homeassistant/components/process.py deleted file mode 100644 index 21343aa977b..00000000000 --- a/homeassistant/components/process.py +++ /dev/null @@ -1,52 +0,0 @@ -""" -homeassistant.components.process -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Provides functionality to watch for specific processes running -on the host machine. - -Author: Markus Stenberg -""" -import logging -import os - -from homeassistant.const import STATE_ON, STATE_OFF -import homeassistant.util as util - -DOMAIN = 'process' -DEPENDENCIES = [] -ENTITY_ID_FORMAT = DOMAIN + '.{}' - -PS_STRING = 'ps awx' - - -def setup(hass, config): - """ Sets up a check if specified processes are running. - - processes: dict mapping entity id to substring to search for - in process list. - """ - - # Deprecated as of 3/7/2015 - logging.getLogger(__name__).warning( - "This component has been deprecated and will be removed in the future." - " Please use sensor.systemmonitor with the process type") - - entities = {ENTITY_ID_FORMAT.format(util.slugify(pname)): pstring - for pname, pstring in config[DOMAIN].items()} - - def update_process_states(time): - """ Check ps for currently running processes and update states. """ - with os.popen(PS_STRING, 'r') as psfile: - lines = list(psfile) - - for entity_id, pstring in entities.items(): - state = STATE_ON if any(pstring in l for l in lines) else STATE_OFF - - hass.states.set(entity_id, state) - - update_process_states(None) - - hass.track_time_change(update_process_states, second=[0, 30]) - - return True diff --git a/homeassistant/helpers/__init__.py b/homeassistant/helpers/__init__.py index 086cddc35e2..286eed4654e 100644 --- a/homeassistant/helpers/__init__.py +++ b/homeassistant/helpers/__init__.py @@ -6,10 +6,6 @@ from homeassistant.const import ( ATTR_ENTITY_ID, CONF_PLATFORM, DEVICE_DEFAULT_NAME) from homeassistant.util import ensure_unique_string, slugify -# Deprecated 3/5/2015 - Moved to homeassistant.helpers.entity -# pylint: disable=unused-import -from .entity import Entity as Device, ToggleEntity as ToggleDevice # noqa - def generate_entity_id(entity_id_format, name, current_ids=None, hass=None): """ Generate a unique entity ID based on given entity IDs or used ids. """ diff --git a/homeassistant/helpers/device.py b/homeassistant/helpers/device.py deleted file mode 100644 index 4c713693c43..00000000000 --- a/homeassistant/helpers/device.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -Deprecated since 3/21/2015 - please use helpers.entity -""" -import logging - -# pylint: disable=unused-import -from .entity import Entity as Device, ToggleEntity as ToggleDevice # noqa - -logging.getLogger(__name__).warning( - 'This file is deprecated. Please use helpers.entity') diff --git a/homeassistant/helpers/device_component.py b/homeassistant/helpers/device_component.py deleted file mode 100644 index 248297a9694..00000000000 --- a/homeassistant/helpers/device_component.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -Deprecated since 3/21/2015 - please use helpers.entity_component -""" -import logging - -# pylint: disable=unused-import -from .entity_component import EntityComponent as DeviceComponent # noqa - -logging.getLogger(__name__).warning( - 'This file is deprecated. Please use helpers.entity_component') diff --git a/homeassistant/util/__init__.py b/homeassistant/util/__init__.py index a75d9837de6..2e399384e63 100644 --- a/homeassistant/util/__init__.py +++ b/homeassistant/util/__init__.py @@ -16,11 +16,7 @@ import random import string from functools import wraps -# DEPRECATED AS OF 4/27/2015 - moved to homeassistant.util.dt package -# pylint: disable=unused-import -from .dt import ( # noqa - datetime_to_str, str_to_datetime, strip_microseconds, - datetime_to_local_str, utcnow) +from .dt import datetime_to_local_str, utcnow RE_SANITIZE_FILENAME = re.compile(r'(~|\.\.|/|\\)') diff --git a/tests/components/test_group.py b/tests/components/test_group.py index a476efdeea0..d1e62b02cdb 100644 --- a/tests/components/test_group.py +++ b/tests/components/test_group.py @@ -199,8 +199,7 @@ class TestComponentsGroup(unittest.TestCase): self.hass, { group.DOMAIN: { - 'second_group': ','.join((self.group_entity_id, - 'light.Bowl')) + 'second_group': (self.group_entity_id, 'light.Bowl') } }))