Use loose version (#24394)

pull/24418/head
Paulus Schoutsen 2019-06-08 08:19:00 -07:00 committed by GitHub
parent 95d460c8bd
commit 929f3c2594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -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')

View File

@ -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):