Fix NetBox string path compatibility
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user