diff --git a/homeassistant/__init__.py b/homeassistant/__init__.py index 062616bf0b4..8ed3d7bc1b6 100644 --- a/homeassistant/__init__.py +++ b/homeassistant/__init__.py @@ -63,11 +63,15 @@ class HomeAssistant(object): @property def config_dir(self): """ DEPRECATED 3/18/2015. Use hass.config.config_dir """ + _LOGGER.warning( + 'hass.config_dir is deprecated. Use hass.config.config_dir') return self.config.config_dir def get_config_path(self, path): - """ DEPRECATED 3/18/2015. Use hass.config.get_config_path """ - return self.config.get_config_path(path) + """ DEPRECATED 3/18/2015. Use hass.config.path """ + _LOGGER.warning( + 'hass.get_config_path is deprecated. Use hass.config.path') + return self.config.path(path) def start(self): """ Start home assistant. """ @@ -854,10 +858,6 @@ class Config(object): # Directory that holds the configuration self.config_dir = os.path.join(os.getcwd(), 'config') - def get_config_path(self, path): - """ Returns path to the file within the config dir. """ - return os.path.join(self.config_dir, path) - def auto_detect(self): """ Will attempt to detect config of Home Assistant. """ # Only detect if location or temp unit missing @@ -892,6 +892,10 @@ class Config(object): if self.time_zone is None: self.time_zone = info['time_zone'] + def path(self, path): + """ Returns path to the file within the config dir. """ + return os.path.join(self.config_dir, path) + def temperature(self, value, unit): """ Converts temperature to user preferred unit if set. """ if not (unit and self.temperature_unit and diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index fc08c6565be..83d966731cd 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -148,7 +148,7 @@ def enable_logging(hass): logging.basicConfig(level=logging.INFO) # Log errors to a file if we have write access to file or config dir - err_log_path = hass.config.get_config_path("home-assistant.log") + err_log_path = hass.config.path("home-assistant.log") err_path_exists = os.path.isfile(err_log_path) # Check if we can write to the error log if it exists or that diff --git a/homeassistant/components/device_tracker/__init__.py b/homeassistant/components/device_tracker/__init__.py index c0e29532b99..ac0c8d483ff 100644 --- a/homeassistant/components/device_tracker/__init__.py +++ b/homeassistant/components/device_tracker/__init__.py @@ -179,8 +179,7 @@ class DeviceTracker(object): # Write new devices to known devices file if not self.invalid_known_devices_file: - known_dev_path = self.hass.config.get_config_path( - KNOWN_DEVICES_FILE) + known_dev_path = self.hass.config.path(KNOWN_DEVICES_FILE) try: # If file does not exist we will write the header too @@ -215,7 +214,7 @@ class DeviceTracker(object): # pylint: disable=too-many-branches def _read_known_devices_file(self): """ Parse and process the known devices file. """ - known_dev_path = self.hass.config.get_config_path(KNOWN_DEVICES_FILE) + known_dev_path = self.hass.config.path(KNOWN_DEVICES_FILE) # Return if no known devices file exists if not os.path.isfile(known_dev_path): diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index 04c187e2d85..e7951afe31a 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -148,7 +148,7 @@ def setup(hass, config): # Load built-in profiles and custom profiles profile_paths = [os.path.join(os.path.dirname(__file__), LIGHT_PROFILES_FILE), - hass.config.get_config_path(LIGHT_PROFILES_FILE)] + hass.config.path(LIGHT_PROFILES_FILE)] profiles = {} for profile_path in profile_paths: diff --git a/homeassistant/components/light/hue.py b/homeassistant/components/light/hue.py index 80fdb47c82c..def43df4fe2 100644 --- a/homeassistant/components/light/hue.py +++ b/homeassistant/components/light/hue.py @@ -52,7 +52,7 @@ def setup_bridge(host, hass, add_devices_callback): try: bridge = phue.Bridge( host, - config_file_path=hass.config.get_config_path(PHUE_CONFIG_FILE)) + config_file_path=hass.config.path(PHUE_CONFIG_FILE)) except ConnectionRefusedError: # Wrong host was given _LOGGER.exception("Error connecting to the Hue bridge at %s", host) diff --git a/homeassistant/components/recorder.py b/homeassistant/components/recorder.py index e31f933e421..84d4c1ecccd 100644 --- a/homeassistant/components/recorder.py +++ b/homeassistant/components/recorder.py @@ -262,7 +262,7 @@ class Recorder(threading.Thread): def _setup_connection(self): """ Ensure database is ready to fly. """ - db_path = self.hass.get_config_path(DB_FILE) + db_path = self.hass.config.path(DB_FILE) self.conn = sqlite3.connect(db_path, check_same_thread=False) self.conn.row_factory = sqlite3.Row diff --git a/homeassistant/components/scheduler/__init__.py b/homeassistant/components/scheduler/__init__.py index 18689b2d7b1..d05d90a903b 100644 --- a/homeassistant/components/scheduler/__init__.py +++ b/homeassistant/components/scheduler/__init__.py @@ -74,7 +74,7 @@ def setup(hass, config): schedule.schedule(hass) return True - with open(hass.config.get_config_path(_SCHEDULE_FILE)) as schedule_file: + with open(hass.config.path(_SCHEDULE_FILE)) as schedule_file: schedule_descriptions = json.load(schedule_file) for schedule_description in schedule_descriptions: diff --git a/homeassistant/loader.py b/homeassistant/loader.py index 14f1632fad3..d38e0df4465 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -46,7 +46,7 @@ def prepare(hass): pkgutil.iter_modules(components.__path__, 'homeassistant.components.')) # Look for available custom components - custom_path = hass.config.get_config_path("custom_components") + custom_path = hass.config.path("custom_components") if os.path.isdir(custom_path): # Ensure we can load custom components using Pythons import diff --git a/tests/test_component_device_scanner.py b/tests/test_component_device_scanner.py index 3b43126681f..2bd392c21d0 100644 --- a/tests/test_component_device_scanner.py +++ b/tests/test_component_device_scanner.py @@ -32,7 +32,7 @@ class TestComponentsDeviceTracker(unittest.TestCase): self.hass = get_test_home_assistant() loader.prepare(self.hass) - self.known_dev_path = self.hass.get_config_path( + self.known_dev_path = self.hass.config.path( device_tracker.KNOWN_DEVICES_FILE) def tearDown(self): # pylint: disable=invalid-name diff --git a/tests/test_component_light.py b/tests/test_component_light.py index c5ccb687e07..eb8a17361bf 100644 --- a/tests/test_component_light.py +++ b/tests/test_component_light.py @@ -29,7 +29,7 @@ class TestLight(unittest.TestCase): """ Stop down stuff we started. """ self.hass.stop() - user_light_file = self.hass.get_config_path(light.LIGHT_PROFILES_FILE) + user_light_file = self.hass.config.path(light.LIGHT_PROFILES_FILE) if os.path.isfile(user_light_file): os.remove(user_light_file) @@ -218,7 +218,7 @@ class TestLight(unittest.TestCase): platform = loader.get_component('light.test') platform.init() - user_light_file = self.hass.get_config_path(light.LIGHT_PROFILES_FILE) + user_light_file = self.hass.config.path(light.LIGHT_PROFILES_FILE) # Setup a wrong light file with open(user_light_file, 'w') as user_file: @@ -234,7 +234,7 @@ class TestLight(unittest.TestCase): platform = loader.get_component('light.test') platform.init() - user_light_file = self.hass.get_config_path(light.LIGHT_PROFILES_FILE) + user_light_file = self.hass.config.path(light.LIGHT_PROFILES_FILE) with open(user_light_file, 'w') as user_file: user_file.write('id,x,y,brightness\n') diff --git a/tests/test_core.py b/tests/test_core.py index 61ac776fba8..a5c37f753b9 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -35,10 +35,10 @@ class TestHomeAssistant(unittest.TestCase): def test_get_config_path(self): """ Test get_config_path method. """ self.assertEqual(os.path.join(os.getcwd(), "config"), - self.hass.config_dir) + self.hass.config.config_dir) self.assertEqual(os.path.join(os.getcwd(), "config", "test.conf"), - self.hass.get_config_path("test.conf")) + self.hass.config.path("test.conf")) def test_block_till_stoped(self): """ Test if we can block till stop service is called. """