Skip to content

Commit

Permalink
Remove netdaemon support
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery committed Apr 15, 2024
1 parent a8a43e3 commit c89e3c2
Show file tree
Hide file tree
Showing 23 changed files with 6 additions and 256 deletions.
1 change: 0 additions & 1 deletion action/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
CATEGORIES = [
"appdaemon",
"integration",
"netdaemon",
"plugin",
"python_script",
"template",
Expand Down
10 changes: 0 additions & 10 deletions custom_components/hacs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ class HacsConfiguration:
experimental: 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 Down Expand Up @@ -799,14 +797,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 @@ -29,7 +29,6 @@
COUNTRY,
DEBUG,
EXPERIMENTAL,
NETDAEMON,
RELEASE_LIMIT,
SIDEPANEL_ICON,
SIDEPANEL_TITLE,
Expand Down Expand Up @@ -239,7 +238,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,
vol.Optional(EXPERIMENTAL, default=hacs.configuration.experimental): 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 @@ -49,7 +49,6 @@ async def async_get_config_entry_diagnostics(
"debug",
"dev",
"experimental",
"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 @@ -29,7 +29,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 @@ -5,7 +5,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 @@ -16,7 +15,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 @@ -28,7 +28,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.filters import filter_content_return_one_of_type
Expand Down Expand Up @@ -84,7 +84,6 @@
"lovelace",
"media-player",
"mediaplayer",
"netdaemon",
"plugin",
"python_script",
"python-script",
Expand Down Expand Up @@ -174,7 +173,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 @@ -937,11 +936,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:
if os.path.exists(
f"{self.content.path.local}/{self.repository_manifest.persistent_directory}"
):
Expand Down
104 changes: 0 additions & 104 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 @@ -49,7 +49,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 @@ -107,33 +107,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)
3 changes: 0 additions & 3 deletions custom_components/hacs/utils/configuration_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
FRONTEND_REPO = "frontend_repo"
FRONTEND_REPO_URL = "frontend_repo_url"
APPDAEMON = "appdaemon"
NETDAEMON = "netdaemon"

# Options:
COUNTRY = "country"
Expand Down Expand Up @@ -42,7 +41,6 @@ def hacs_config_option_schema(options: dict = {}) -> dict:
COUNTRY: "ALL",
DEBUG: False,
EXPERIMENTAL: False,
NETDAEMON: False,
RELEASE_LIMIT: 5,
SIDEPANEL_ICON: "hacs:hacs",
SIDEPANEL_TITLE: "HACS",
Expand All @@ -55,7 +53,6 @@ def hacs_config_option_schema(options: dict = {}) -> dict:
vol.Optional(RELEASE_LIMIT, default=options.get(RELEASE_LIMIT)): int,
vol.Optional(COUNTRY, default=options.get(COUNTRY)): vol.In(LOCALE),
vol.Optional(APPDAEMON, default=options.get(APPDAEMON)): bool,
vol.Optional(NETDAEMON, default=options.get(NETDAEMON)): bool,
vol.Optional(DEBUG, default=options.get(DEBUG)): bool,
vol.Optional(EXPERIMENTAL, default=options.get(EXPERIMENTAL)): bool,
vol.Exclusive(FRONTEND_REPO, PATH_OR_URL): str,
Expand Down
1 change: 0 additions & 1 deletion custom_components/hacs/utils/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def is_safe(hacs: HacsBase, path: str | Path) -> bool:
"""Helper to check if path is safe to remove."""
return Path(path).as_posix() not in (
Path(f"{hacs.core.config_path}/{hacs.configuration.appdaemon_path}").as_posix(),
Path(f"{hacs.core.config_path}/{hacs.configuration.netdaemon_path}").as_posix(),
Path(f"{hacs.core.config_path}/{hacs.configuration.plugin_path}").as_posix(),
Path(f"{hacs.core.config_path}/{hacs.configuration.python_script_path}").as_posix(),
Path(f"{hacs.core.config_path}/{hacs.configuration.theme_path}").as_posix(),
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 @@ -132,15 +132,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 @@ -31,7 +31,6 @@
from custom_components.hacs.repositories import (
HacsAppdaemonRepository,
HacsIntegrationRepository,
HacsNetdaemonRepository,
HacsPluginRepository,
HacsPythonScriptRepository,
HacsTemplateRepository,
Expand Down Expand Up @@ -200,13 +199,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 @@ -348,7 +340,6 @@ async def setup_integration(hass: HomeAssistant, check_report_issue: None) -> No
options={
"experimental": True,
"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"
3 changes: 0 additions & 3 deletions tests/hacsbase/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ def test_configuration_and_option():
assert isinstance(config.appdaemon, bool)
assert not config.appdaemon

assert isinstance(config.netdaemon, bool)
assert not config.netdaemon

assert isinstance(config.python_script, bool)
assert not config.python_script

Expand Down

0 comments on commit c89e3c2

Please sign in to comment.