Skip to content

Commit d1cb1a4

Browse files
committed
Make default path a constant
1 parent 14651ac commit d1cb1a4

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

matter_server/server/const.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Server-only constants for the Python Matter Server."""
2-
2+
import pathlib
3+
from typing import Final
34

45
# The minimum schema version (of a client) the server can support
56
MIN_SCHEMA_VERSION = 5
@@ -8,3 +9,13 @@
89
# only bump if the format of the data in MatterNodeData changed
910
# and a full re-interview is mandatory
1011
DATA_MODEL_SCHEMA_VERSION = 6
12+
13+
# Keep default location inherited from early version of the Python
14+
# bindings.
15+
DEFAULT_PAA_ROOT_CERTS_DIR: Final[pathlib.Path] = (
16+
pathlib.Path(__file__)
17+
.parent.resolve()
18+
.parent.resolve()
19+
.parent.resolve()
20+
.joinpath("credentials/development/paa-root-certs")
21+
)

matter_server/server/server.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import ipaddress
88
import logging
99
import os
10-
import pathlib
1110
from pathlib import Path
1211
import traceback
1312
from typing import TYPE_CHECKING, Any, Callable, Set, cast
@@ -30,7 +29,7 @@
3029
ServerInfoMessage,
3130
)
3231
from ..server.client_handler import WebsocketClientHandler
33-
from .const import MIN_SCHEMA_VERSION
32+
from .const import DEFAULT_PAA_ROOT_CERTS_DIR, MIN_SCHEMA_VERSION
3433
from .device_controller import MatterDeviceController
3534
from .stack import MatterStack
3635
from .storage import StorageController
@@ -111,13 +110,7 @@ def __init__(
111110
self.listen_addresses = listen_addresses
112111
self.primary_interface = primary_interface
113112
if paa_root_cert_dir is None:
114-
self.paa_root_cert_dir = (
115-
pathlib.Path(__file__)
116-
.parent.resolve()
117-
.parent.resolve()
118-
.parent.resolve()
119-
.joinpath("credentials/development/paa-root-certs")
120-
)
113+
self.paa_root_cert_dir = DEFAULT_PAA_ROOT_CERTS_DIR
121114
else:
122115
self.paa_root_cert_dir = Path(paa_root_cert_dir).absolute()
123116
self.logger = logging.getLogger(__name__)

0 commit comments

Comments
 (0)