Allow disabling integrations in manifest, block uuid package being installed and disable ezviz (#38444)
This commit is contained in:
parent
eaac00acfc
commit
2a9da208d4
11 changed files with 40 additions and 5 deletions
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
|
@ -46,7 +46,7 @@ jobs:
|
|||
run: |
|
||||
python -m venv venv
|
||||
. venv/bin/activate
|
||||
pip install -U pip==20.1.1 setuptools
|
||||
pip install -U pip setuptools
|
||||
pip install -r requirements.txt -r requirements_test.txt
|
||||
# Uninstalling typing as a workaround. Eventually we should make sure
|
||||
# all our dependencies drop typing.
|
||||
|
@ -603,7 +603,7 @@ jobs:
|
|||
run: |
|
||||
python -m venv venv
|
||||
. venv/bin/activate
|
||||
pip install -U pip==20.1.1 setuptools wheel
|
||||
pip install -U pip setuptools wheel
|
||||
pip install -r requirements_all.txt
|
||||
pip install -r requirements_test.txt
|
||||
# Uninstalling typing as a workaround. Eventually we should make sure
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import asyncio
|
||||
import logging
|
||||
|
||||
# pylint: disable=import-error
|
||||
from haffmpeg.tools import IMAGE_JPEG, ImageFrame
|
||||
from pyezviz.camera import EzvizCamera
|
||||
from pyezviz.client import EzvizClient, PyEzvizError
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"disabled": "Dependency contains code that breaks Home Assistant.",
|
||||
"domain": "ezviz",
|
||||
"name": "Ezviz",
|
||||
"documentation": "https://www.home-assistant.io/integrations/ezviz",
|
||||
|
|
|
@ -271,6 +271,11 @@ class Integration:
|
|||
"""Return name."""
|
||||
return cast(str, self.manifest["name"])
|
||||
|
||||
@property
|
||||
def disabled(self) -> Optional[str]:
|
||||
"""Return reason integration is disabled."""
|
||||
return cast(Optional[str], self.manifest.get("disabled"))
|
||||
|
||||
@property
|
||||
def domain(self) -> str:
|
||||
"""Return domain."""
|
||||
|
|
|
@ -44,3 +44,6 @@ enum34==1000000000.0.0
|
|||
|
||||
# This is a old unmaintained library and is replaced with pycryptodome
|
||||
pycrypto==1000000000.0.0
|
||||
|
||||
# This is built-in and breaks pip if installed
|
||||
uuid==1000000000.0.0
|
||||
|
|
|
@ -124,6 +124,10 @@ async def _async_setup_component(
|
|||
log_error("Integration not found.")
|
||||
return False
|
||||
|
||||
if integration.disabled:
|
||||
log_error(f"dependency is disabled - {integration.disabled}")
|
||||
return False
|
||||
|
||||
# Validate all dependencies exist and there are no circular dependencies
|
||||
if not await integration.resolve_dependencies():
|
||||
return False
|
||||
|
|
|
@ -1334,9 +1334,6 @@ pyephember==0.3.1
|
|||
# homeassistant.components.everlights
|
||||
pyeverlights==0.1.0
|
||||
|
||||
# homeassistant.components.ezviz
|
||||
pyezviz==0.1.5
|
||||
|
||||
# homeassistant.components.fido
|
||||
pyfido==2.1.1
|
||||
|
||||
|
|
|
@ -71,6 +71,9 @@ enum34==1000000000.0.0
|
|||
|
||||
# This is a old unmaintained library and is replaced with pycryptodome
|
||||
pycrypto==1000000000.0.0
|
||||
|
||||
# This is built-in and breaks pip if installed
|
||||
uuid==1000000000.0.0
|
||||
"""
|
||||
|
||||
IGNORE_PRE_COMMIT_HOOK_ID = (
|
||||
|
@ -178,6 +181,9 @@ def gather_requirements_from_manifests(errors, reqs):
|
|||
errors.append(f"The manifest for integration {domain} is invalid.")
|
||||
continue
|
||||
|
||||
if integration.disabled:
|
||||
continue
|
||||
|
||||
process_requirements(
|
||||
errors, integration.requirements, f"homeassistant.components.{domain}", reqs
|
||||
)
|
||||
|
|
|
@ -54,6 +54,7 @@ MANIFEST_SCHEMA = vol.Schema(
|
|||
vol.Optional("dependencies"): [str],
|
||||
vol.Optional("after_dependencies"): [str],
|
||||
vol.Required("codeowners"): [str],
|
||||
vol.Optional("disabled"): str,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -73,6 +73,11 @@ class Integration:
|
|||
"""Integration domain."""
|
||||
return self.path.name
|
||||
|
||||
@property
|
||||
def disabled(self) -> Optional[str]:
|
||||
"""List of disabled."""
|
||||
return self.manifest.get("disabled")
|
||||
|
||||
@property
|
||||
def requirements(self) -> List[str]:
|
||||
"""List of requirements."""
|
||||
|
|
|
@ -583,3 +583,15 @@ async def test_parallel_entry_setup(hass):
|
|||
await setup.async_setup_component(hass, "comp", {})
|
||||
|
||||
assert calls == [1, 2, 1, 2]
|
||||
|
||||
|
||||
async def test_integration_disabled(hass, caplog):
|
||||
"""Test we can disable an integration."""
|
||||
disabled_reason = "Dependency contains code that breaks Home Assistant"
|
||||
mock_integration(
|
||||
hass,
|
||||
MockModule("test_component1", partial_manifest={"disabled": disabled_reason}),
|
||||
)
|
||||
result = await setup.async_setup_component(hass, "test_component1", {})
|
||||
assert not result
|
||||
assert disabled_reason in caplog.text
|
||||
|
|
Loading…
Add table
Reference in a new issue