1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Many changes to cleanup config directory and lib installations.

Cleaned up default config directory determination.
Made bootstrap creators for HA always set config directory.
Made bootstrap creators set the local library in the Python Path.
Moved all exceptions to their own file to make imports easier.
Moved default configuration directory be in the users’ profile.
Moved pip installs to be done to a lib folder in the config directory.
Reduced requirements.txt to only the barebones reqs.
This commit is contained in:
Ryan Kraus
2015-08-29 21:11:24 -04:00
parent 18e32165a4
commit 6fdf9b8d7c
7 changed files with 53 additions and 150 deletions

View File

@@ -7,6 +7,7 @@ of entities and react to changes.
"""
import os
import sys
import time
import logging
import threading
@@ -21,9 +22,12 @@ from homeassistant.const import (
EVENT_CALL_SERVICE, ATTR_NOW, ATTR_DOMAIN, ATTR_SERVICE, MATCH_ALL,
EVENT_SERVICE_EXECUTED, ATTR_SERVICE_CALL_ID, EVENT_SERVICE_REGISTERED,
TEMP_CELCIUS, TEMP_FAHRENHEIT, ATTR_FRIENDLY_NAME)
from homeassistant.exceptions import (
HomeAssistantError, InvalidEntityFormatError, NoEntitySpecifiedError)
import homeassistant.util as util
import homeassistant.util.dt as date_util
import homeassistant.helpers.temperature as temp_helper
from homeassistant.config import get_default_config_dir
DOMAIN = "homeassistant"
@@ -660,7 +664,11 @@ class Config(object):
self.api = None
# Directory that holds the configuration
self.config_dir = os.path.join(os.getcwd(), 'config')
self.config_dir = get_default_config_dir()
def mount_local_path(self):
""" Add local library to Python Path """
sys.path.insert(0, self.path('lib'))
def path(self, *path):
""" Returns path to the file within the config dir. """
@@ -695,21 +703,6 @@ class Config(object):
}
class HomeAssistantError(Exception):
""" General Home Assistant exception occured. """
pass
class InvalidEntityFormatError(HomeAssistantError):
""" When an invalid formatted entity is encountered. """
pass
class NoEntitySpecifiedError(HomeAssistantError):
""" When no entity is specified. """
pass
def create_timer(hass, interval=TIMER_INTERVAL):
""" Creates a timer. Timer will start on HOMEASSISTANT_START. """
# We want to be able to fire every time a minute starts (seconds=0).