|
33 | 33 | ) |
34 | 34 | from simvue.api.url import URL |
35 | 35 |
|
36 | | -logging.basicConfig(level=logging.INFO) |
37 | | - |
38 | 36 | try: |
39 | 37 | from typing import Self |
40 | 38 | except ImportError: |
@@ -199,6 +197,12 @@ def __init__( |
199 | 197 | self._read_only: bool = _read_only |
200 | 198 | self._is_set: bool = False |
201 | 199 | self._endpoint: str = getattr(self, "_endpoint", f"{self._label}s") |
| 200 | + |
| 201 | + # For simvue object initialisation, unlike the server there is no nested |
| 202 | + # arguments, however this means that there are extra keys during post which |
| 203 | + # need removing, this attribute handles that and should be set in subclasses. |
| 204 | + self._local_only_args: list[str] = [] |
| 205 | + |
202 | 206 | self._identifier: str | None = ( |
203 | 207 | identifier if identifier is not None else f"offline_{uuid.uuid1()}" |
204 | 208 | ) |
@@ -635,6 +639,10 @@ def _post_single( |
635 | 639 | if not is_json: |
636 | 640 | kwargs = msgpack.packb(data or kwargs, use_bin_type=True) |
637 | 641 |
|
| 642 | + # Remove any extra keys |
| 643 | + for key in self._local_only_args: |
| 644 | + _ = (data or kwargs).pop(key, None) |
| 645 | + |
638 | 646 | _response = sv_post( |
639 | 647 | url=f"{self._base_url}", |
640 | 648 | headers=self._headers | {"Content-Type": "application/msgpack"}, |
@@ -672,6 +680,11 @@ def _post_single( |
672 | 680 | def _put(self, **kwargs) -> dict[str, typing.Any]: |
673 | 681 | if not self.url: |
674 | 682 | raise RuntimeError(f"Identifier for instance of {self._label} Unknown") |
| 683 | + |
| 684 | + # Remove any extra keys |
| 685 | + for key in self._local_only_args: |
| 686 | + _ = kwargs.pop(key, None) |
| 687 | + |
675 | 688 | _response = sv_put( |
676 | 689 | url=f"{self.url}", headers=self._headers, data=kwargs, is_json=True |
677 | 690 | ) |
|
0 commit comments