From 929f3c25949ecd090e532de46281186f260ac4ea Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 8 Jun 2019 08:19:00 -0700 Subject: [PATCH] Use loose version (#24394) --- homeassistant/config.py | 10 +++++----- tests/test_config.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/homeassistant/config.py b/homeassistant/config.py index 7e8bcec08a5..3443e98e928 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -1,7 +1,7 @@ """Module to help with parsing and generating configuration files.""" from collections import OrderedDict # pylint: disable=no-name-in-module -from distutils.version import StrictVersion # pylint: disable=import-error +from distutils.version import LooseVersion # pylint: disable=import-error import logging import os import re @@ -334,15 +334,15 @@ def process_ha_config_upgrade(hass: HomeAssistant) -> None: _LOGGER.info("Upgrading configuration directory from %s to %s", conf_version, __version__) - version_obj = StrictVersion(conf_version) + version_obj = LooseVersion(conf_version) - if version_obj < StrictVersion('0.50'): + if version_obj < LooseVersion('0.50'): # 0.50 introduced persistent deps dir. lib_path = hass.config.path('deps') if os.path.isdir(lib_path): shutil.rmtree(lib_path) - if version_obj < StrictVersion('0.92'): + if version_obj < LooseVersion('0.92'): # 0.92 moved google/tts.py to google_translate/tts.py config_path = find_config_file(hass.config.config_dir) assert config_path is not None @@ -360,7 +360,7 @@ def process_ha_config_upgrade(hass: HomeAssistant) -> None: _LOGGER.exception("Migrating to google_translate tts failed") pass - if version_obj < StrictVersion('0.94.0b6') and is_docker_env(): + if version_obj < LooseVersion('0.94') and is_docker_env(): # In 0.94 we no longer install packages inside the deps folder when # running inside a Docker container. lib_path = hass.config.path('deps') diff --git a/tests/test_config.py b/tests/test_config.py index 8e983c673c5..1adb127cfb0 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -281,7 +281,7 @@ def test_remove_lib_on_upgrade(mock_docker, mock_os, mock_shutil, hass): @mock.patch('homeassistant.config.is_docker_env', return_value=True) def test_remove_lib_on_upgrade_94(mock_docker, mock_os, mock_shutil, hass): """Test removal of library on upgrade from before 0.94 and in Docker.""" - ha_version = '0.94.0b5' + ha_version = '0.93.0.dev0' mock_os.path.isdir = mock.Mock(return_value=True) mock_open = mock.mock_open() with mock.patch('homeassistant.config.open', mock_open, create=True):