Fix NetBox string path compatibility
CI / php-store (push) Waiting to run
CI / python-components (push) Waiting to run

This commit is contained in:
2026-08-24 22:36:28 +02:00
parent 2063d9ca3c
commit 3028bf522c
6 changed files with 36 additions and 6 deletions
+9 -2
View File
@@ -11,6 +11,12 @@ class RuntimeConfigurationError(RuntimeError):
pass
def _netbox_root(django_settings: object) -> Path:
"""Return NETBOX_ROOT while supporting NetBox settings that expose paths as strings."""
base_dir = Path(getattr(django_settings, "BASE_DIR"))
return Path(getattr(django_settings, "NETBOX_ROOT", base_dir.parent))
def _argv_list(value: object, setting: str) -> tuple[tuple[str, ...], ...]:
if not isinstance(value, (list, tuple)):
raise RuntimeConfigurationError(f"{setting} must be a list of argv lists.")
@@ -160,11 +166,12 @@ class RuntimeSettings:
defaults.update(plugin_settings)
release = getattr(django_settings, "RELEASE", None)
version = getattr(release, "version", None) or django_settings.VERSION
base_dir = Path(django_settings.BASE_DIR)
return cls.from_mapping(
defaults,
configuration_dir=django_settings.CONFIGURATION_DIR,
netbox_root=getattr(django_settings, "NETBOX_ROOT", django_settings.BASE_DIR.parent),
base_dir=django_settings.BASE_DIR,
netbox_root=_netbox_root(django_settings),
base_dir=base_dir,
netbox_version=version,
)