Skip to content
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
2 changes: 1 addition & 1 deletion homeassistant/components/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
vol.Optional(ATTR_PUSH_SOUNDS): list
}, extra=vol.ALLOW_EXTRA)

CONFIGURATION_FILE = 'ios.conf'
CONFIGURATION_FILE = '.ios.conf'

CONFIG_FILE = {ATTR_DEVICES: {}}

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/notify/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def send_message(self, message="", **kwargs):

for target in targets:
if target not in ios.enabled_push_ids():
_LOGGER.error("The target (%s) does not exist in ios.conf.",
_LOGGER.error("The target (%s) does not exist in .ios.conf.",
targets)
return

Expand Down
10 changes: 10 additions & 0 deletions homeassistant/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
CONFIG_DIR_NAME = '.homeassistant'
DATA_CUSTOMIZE = 'hass_customize'

FILE_MIGRATION = [
Copy link
Copy Markdown
Contributor

@emlove emlove Jun 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a dict instead? Just fewer brackets.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may change this in the future, more a fan of an array, since logically to me its not really a key value pair, but a list of tuples.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

["ios.conf", ".ios.conf"],
]

DEFAULT_CORE_CONFIG = (
# Tuples (attribute, default, auto detect property, description)
(CONF_NAME, 'Home', None, 'Name of the location where Home Assistant is '
Expand Down Expand Up @@ -292,6 +296,12 @@ def process_ha_config_upgrade(hass):
with open(version_path, 'wt') as outp:
outp.write(__version__)

_LOGGER.info('Migrating old system config files to new locations')
for oldf, newf in FILE_MIGRATION:
if os.path.isfile(hass.config.path(oldf)):
_LOGGER.info('Migrating %s to %s', oldf, newf)
os.rename(hass.config.path(oldf), hass.config.path(newf))


@callback
def async_log_exception(ex, domain, config, hass):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""Constants used by Home Assistant components."""
MAJOR_VERSION = 0
MINOR_VERSION = 46
PATCH_VERSION = '0.dev0'
PATCH_VERSION = '0.dev1'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change was done so that people running dev would also get the update. Otherwise we would break anyone running dev. This prevents thats.

__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
REQUIRED_PYTHON_VER = (3, 4, 2)
Expand Down
50 changes: 50 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,56 @@ def test_not_remove_lib_if_not_upgrade(self, mock_os, mock_shutil):
assert mock_os.path.isdir.call_count == 0
assert mock_shutil.rmtree.call_count == 0

@mock.patch('homeassistant.config.shutil')
@mock.patch('homeassistant.config.os')
def test_migrate_file_on_upgrade(self, mock_os, mock_shutil):
"""Test migrate of config files on upgrade."""
ha_version = '0.7.0'

mock_os.path.isdir = mock.Mock(return_value=True)

mock_open = mock.mock_open()

def mock_isfile(filename):
return True

with mock.patch('homeassistant.config.open', mock_open, create=True), \
mock.patch('homeassistant.config.os.path.isfile', mock_isfile):
opened_file = mock_open.return_value
# pylint: disable=no-member
opened_file.readline.return_value = ha_version

self.hass.config.path = mock.Mock()

config_util.process_ha_config_upgrade(self.hass)

assert mock_os.rename.call_count == 1

@mock.patch('homeassistant.config.shutil')
@mock.patch('homeassistant.config.os')
def test_migrate_no_file_on_upgrade(self, mock_os, mock_shutil):
"""Test not migrating config files on upgrade."""
ha_version = '0.7.0'

mock_os.path.isdir = mock.Mock(return_value=True)

mock_open = mock.mock_open()

def mock_isfile(filename):
return False

with mock.patch('homeassistant.config.open', mock_open, create=True), \
mock.patch('homeassistant.config.os.path.isfile', mock_isfile):
opened_file = mock_open.return_value
# pylint: disable=no-member
opened_file.readline.return_value = ha_version

self.hass.config.path = mock.Mock()

config_util.process_ha_config_upgrade(self.hass)

assert mock_os.rename.call_count == 0

def test_loading_configuration(self):
"""Test loading core config onto hass object."""
self.hass.config = mock.Mock()
Expand Down