Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove netdaemon support #3588

Merged
merged 4 commits into from
Jul 5, 2024
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
1 change: 0 additions & 1 deletion action/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
CATEGORIES = [
"appdaemon",
"integration",
"netdaemon",
"plugin",
"python_script",
"template",
Expand Down
12 changes: 1 addition & 11 deletions custom_components/hacs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ class HacsConfiguration:
dev: bool = False
frontend_repo_url: str = ""
frontend_repo: str = ""
netdaemon_path: str = "netdaemon/apps/"
netdaemon: bool = False
plugin_path: str = "www/community/"
python_script_path: str = "python_scripts/"
python_script: bool = False
Expand All @@ -142,7 +140,7 @@ def update_from_dict(self, data: dict) -> None:
raise HacsException("Configuration is not valid.")

for key in data:
if key == "experimental":
if key in {"experimental", "netdaemon"}:
continue
self.__setattr__(key, data[key])

Expand Down Expand Up @@ -784,14 +782,6 @@ def set_active_categories(self) -> None:

if self.configuration.appdaemon:
self.enable_hacs_category(HacsCategory.APPDAEMON)
if self.configuration.netdaemon:
if self.repositories.category_downloaded(HacsCategory.NETDAEMON):
self.log.warning(
"NetDaemon in HACS is deprectaded. It will stop working in the future. "
"Please remove all your current NetDaemon repositories from HACS "
"and download them manually if you want to continue using them."
)
self.enable_hacs_category(HacsCategory.NETDAEMON)

async def async_load_hacs_from_github(self, _=None) -> None:
"""Load HACS from GitHub."""
Expand Down
2 changes: 0 additions & 2 deletions custom_components/hacs/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
APPDAEMON,
COUNTRY,
DEBUG,
NETDAEMON,
RELEASE_LIMIT,
SIDEPANEL_ICON,
SIDEPANEL_TITLE,
Expand Down Expand Up @@ -246,7 +245,6 @@ async def async_step_user(self, user_input=None):
vol.Optional(RELEASE_LIMIT, default=hacs.configuration.release_limit): int,
vol.Optional(COUNTRY, default=hacs.configuration.country): vol.In(LOCALE),
vol.Optional(APPDAEMON, default=hacs.configuration.appdaemon): bool,
vol.Optional(NETDAEMON, default=hacs.configuration.netdaemon): bool,
vol.Optional(DEBUG, default=hacs.configuration.debug): bool,
}

Expand Down
1 change: 0 additions & 1 deletion custom_components/hacs/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ async def async_get_config_entry_diagnostics(
"country",
"debug",
"dev",
"netdaemon",
"python_script",
"release_limit",
"theme",
Expand Down
1 change: 0 additions & 1 deletion custom_components/hacs/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class HacsCategory(StrEnum):
INTEGRATION = "integration"
LOVELACE = "lovelace"
PLUGIN = "plugin" # Kept for legacy purposes
NETDAEMON = "netdaemon"
PYTHON_SCRIPT = "python_script"
TEMPLATE = "template"
THEME = "theme"
Expand Down
2 changes: 0 additions & 2 deletions custom_components/hacs/repositories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from .appdaemon import HacsAppdaemonRepository
from .base import HacsRepository
from .integration import HacsIntegrationRepository
from .netdaemon import HacsNetdaemonRepository
from .plugin import HacsPluginRepository
from .python_script import HacsPythonScriptRepository
from .template import HacsTemplateRepository
Expand All @@ -17,7 +16,6 @@
HacsCategory.INTEGRATION: HacsIntegrationRepository,
HacsCategory.PYTHON_SCRIPT: HacsPythonScriptRepository,
HacsCategory.APPDAEMON: HacsAppdaemonRepository,
HacsCategory.NETDAEMON: HacsNetdaemonRepository,
HacsCategory.PLUGIN: HacsPluginRepository,
HacsCategory.TEMPLATE: HacsTemplateRepository,
}
11 changes: 3 additions & 8 deletions custom_components/hacs/repositories/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
HacsRepositoryExistException,
)
from ..types import DownloadableContent
from ..utils.backup import Backup, BackupNetDaemon
from ..utils.backup import Backup
from ..utils.decode import decode_content
from ..utils.decorator import concurrent
from ..utils.file_system import async_exists, async_remove, async_remove_directory
Expand Down Expand Up @@ -85,7 +85,6 @@
"lovelace",
"media-player",
"mediaplayer",
"netdaemon",
"plugin",
"python_script",
"python-script",
Expand Down Expand Up @@ -175,7 +174,7 @@ class RepositoryData:
@property
def name(self):
"""Return the name."""
if self.category in ["integration", "netdaemon"]:
if self.category == "integration":
return self.domain
return self.full_name.split("/")[-1]

Expand Down Expand Up @@ -934,11 +933,7 @@ async def async_install_repository(self, *, version: str | None = None, **_) ->
{"repository": self.data.full_name, "progress": 40},
)

if self.data.installed and self.data.category == "netdaemon":
persistent_directory = BackupNetDaemon(hacs=self.hacs, repository=self)
await self.hacs.hass.async_add_executor_job(persistent_directory.create)

elif self.repository_manifest.persistent_directory:
if self.repository_manifest.persistent_directory:
ludeeus marked this conversation as resolved.
Show resolved Hide resolved
if await async_exists(
self.hacs.hass,
f"{self.content.path.local}/{self.repository_manifest.persistent_directory}",
Expand Down
105 changes: 0 additions & 105 deletions custom_components/hacs/repositories/netdaemon.py

This file was deleted.

1 change: 0 additions & 1 deletion custom_components/hacs/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"release_limit": "Number of releases to show",
"debug": "Enable debug",
"appdaemon": "Enable AppDaemon apps discovery & tracking",
"netdaemon": "[DEPRECATED] Enable NetDaemon apps discovery & tracking",
"sidepanel_icon": "Side panel icon",
"sidepanel_title": "Side panel title"
}
Expand Down
30 changes: 0 additions & 30 deletions custom_components/hacs/utils/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,33 +108,3 @@ def cleanup(self) -> None:
while os.path.exists(self.backup_path):
sleep(0.1)
self.hacs.log.debug("Backup dir %s cleared", self.backup_path)


class BackupNetDaemon(Backup):
"""BackupNetDaemon."""

def create(self) -> None:
"""Create a backup in /tmp"""
if not self._init_backup_dir():
return

for filename in os.listdir(self.repository.content.path.local):
if not filename.endswith(".yaml"):
continue

source_file_name = f"{self.repository.content.path.local}/{filename}"
target_file_name = f"{self.backup_path}/{filename}"
shutil.copyfile(source_file_name, target_file_name)

def restore(self) -> None:
"""Create a backup in /tmp"""
if not os.path.exists(self.backup_path):
return

for filename in os.listdir(self.backup_path):
if not filename.endswith(".yaml"):
continue

source_file_name = f"{self.backup_path}/{filename}"
target_file_name = f"{self.repository.content.path.local}/{filename}"
shutil.copyfile(source_file_name, target_file_name)
1 change: 0 additions & 1 deletion custom_components/hacs/utils/configuration_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
SIDEPANEL_TITLE = "sidepanel_title"
SIDEPANEL_ICON = "sidepanel_icon"
APPDAEMON = "appdaemon"
NETDAEMON = "netdaemon"

# Options:
COUNTRY = "country"
Expand Down
3 changes: 0 additions & 3 deletions custom_components/hacs/utils/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@
def _get_safe_paths(
config_path: str,
appdaemon_path: str,
netdaemon_path: str,
plugin_path: str,
python_script_path: str,
theme_path: str,
) -> set[str]:
"""Get safe paths."""
return {
Path(f"{config_path}/{appdaemon_path}").as_posix(),
Path(f"{config_path}/{netdaemon_path}").as_posix(),
Path(f"{config_path}/{plugin_path}").as_posix(),
Path(f"{config_path}/{python_script_path}").as_posix(),
Path(f"{config_path}/{theme_path}").as_posix(),
Expand All @@ -37,7 +35,6 @@ def is_safe(hacs: HacsBase, path: str | Path) -> bool:
return Path(path).as_posix() not in _get_safe_paths(
hacs.core.config_path,
configuration.appdaemon_path,
configuration.netdaemon_path,
configuration.plugin_path,
configuration.python_script_path,
configuration.theme_path,
Expand Down
6 changes: 0 additions & 6 deletions custom_components/hacs/utils/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,9 @@ def validate_version(data: Any) -> Any:
vol.Required("manifest_name"): str,
}

V2_NETDAEMON_DATA_JSON_SCHEMA = {
**V2_COMMON_DATA_JSON_SCHEMA,
vol.Required("domain"): str,
}

_V2_REPO_SCHEMAS = {
"appdaemon": V2_COMMON_DATA_JSON_SCHEMA,
"integration": V2_INTEGRATION_DATA_JSON_SCHEMA,
"netdaemon": V2_NETDAEMON_DATA_JSON_SCHEMA,
"plugin": V2_COMMON_DATA_JSON_SCHEMA,
"python_script": V2_COMMON_DATA_JSON_SCHEMA,
"template": V2_COMMON_DATA_JSON_SCHEMA,
Expand Down
9 changes: 0 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from custom_components.hacs.repositories import (
HacsAppdaemonRepository,
HacsIntegrationRepository,
HacsNetdaemonRepository,
HacsPluginRepository,
HacsPythonScriptRepository,
HacsTemplateRepository,
Expand Down Expand Up @@ -222,13 +221,6 @@ def repository_appdaemon(hacs):
yield dummy_repository_base(hacs, repository_obj)


@pytest.fixture
def repository_netdaemon(hacs):
"""Fixtrue for HACS netdaemon repository object"""
repository_obj = HacsNetdaemonRepository(hacs, "test/test")
yield dummy_repository_base(hacs, repository_obj)


class SnapshotFixture(Snapshot):
async def assert_hacs_data(
self,
Expand Down Expand Up @@ -370,7 +362,6 @@ async def setup_integration(hass: HomeAssistant, check_report_issue: None) -> No
config_entry = create_config_entry(
options={
"appdaemon": True,
"netdaemon": True,
}
)
await common_setup_integration(hass, config_entry)
Expand Down
1 change: 0 additions & 1 deletion tests/fixtures/v2-netdaemon-data.json

This file was deleted.

30 changes: 1 addition & 29 deletions tests/hacsbase/test_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# pylint: disable=missing-docstring
import os

from custom_components.hacs.utils.backup import Backup, BackupNetDaemon
from custom_components.hacs.utils.backup import Backup


def test_file(hacs, tmpdir):
Expand Down Expand Up @@ -42,31 +42,3 @@ def test_muilti(hacs, tmpdir):
backup = Backup(hacs=hacs, local_path=f"{tmpdir.dirname}/dummy_directory")
backup.create()
backup.create()


def test_netdaemon_backup(hacs, repository_netdaemon):
repository = repository_netdaemon
repository.content.path.local = repository.localpath
os.makedirs(repository.content.path.local, exist_ok=True)
backup = BackupNetDaemon(hacs=hacs, repository=repository)
backup.cleanup()
with open(f"{repository.content.path.local}/dummy_file.yaml", "w") as dummy:
dummy.write("test: test")
with open(f"{repository.content.path.local}/dummy_file.yaml") as dummy:
content = dummy.read()
assert content == "test: test"
assert not os.path.exists(backup.backup_path)
os.makedirs(backup.backup_path, exist_ok=True)
backup.create()
assert os.path.exists(backup.backup_path)
with open(f"{repository.content.path.local}/dummy_file.yaml", "w") as dummy:
dummy.write("tests: tests")
with open(f"{repository.content.path.local}/dummy_file.yaml") as dummy:
content = dummy.read()
assert content == "tests: tests"
backup.restore()
backup.cleanup()
assert not os.path.exists(backup.backup_path)
with open(f"{repository.content.path.local}/dummy_file.yaml") as dummy:
content = dummy.read()
assert content == "test: test"
Loading