From 1d98c9bb148484dee3c9ff8dfeddefece579f780 Mon Sep 17 00:00:00 2001 From: gifrerenom Date: Wed, 20 Dec 2023 11:23:41 +0000 Subject: [PATCH] Multiple bug fixes: - `common` > `tests` > `InMemoryObjectDatabase.py`: enhance log error reporting - `common` > `tools` > `descriptor` > `Tools.py`: correct formatting of non-string resource_values in custom config rules in method `format_custom_config_rules()` - `common` > `tools` > `service` > `GenericRestServer.py`: correct format of reported listen URL --- src/common/tests/InMemoryObjectDatabase.py | 4 +++- src/common/tools/descriptor/Tools.py | 2 ++ src/common/tools/service/GenericRestServer.py | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/common/tests/InMemoryObjectDatabase.py b/src/common/tests/InMemoryObjectDatabase.py index 21697a435..f5f98872a 100644 --- a/src/common/tests/InMemoryObjectDatabase.py +++ b/src/common/tests/InMemoryObjectDatabase.py @@ -37,7 +37,9 @@ class InMemoryObjectDatabase: LOGGER.debug('[get_entry] BEFORE database={:s}'.format(str(self._database))) container = self._get_container(container_name) if entry_uuid not in container: - context.abort(grpc.StatusCode.NOT_FOUND, str('{:s}({:s}) not found'.format(container_name, entry_uuid))) + MSG = '{:s}({:s}) not found; available({:s})' + msg = str(MSG.format(container_name, entry_uuid, str(container.keys()))) + context.abort(grpc.StatusCode.NOT_FOUND, msg) return container[entry_uuid] def set_entry(self, container_name : str, entry_uuid : str, entry : Any) -> Any: diff --git a/src/common/tools/descriptor/Tools.py b/src/common/tools/descriptor/Tools.py index f03c635b8..3126f2bce 100644 --- a/src/common/tools/descriptor/Tools.py +++ b/src/common/tools/descriptor/Tools.py @@ -57,6 +57,8 @@ def format_custom_config_rules(config_rules : List[Dict]) -> List[Dict]: if isinstance(custom_resource_value, (dict, list)): custom_resource_value = json.dumps(custom_resource_value, sort_keys=True, indent=0) config_rule['custom']['resource_value'] = custom_resource_value + elif not isinstance(custom_resource_value, str): + config_rule['custom']['resource_value'] = str(custom_resource_value) return config_rules def format_device_custom_config_rules(device : Dict) -> Dict: diff --git a/src/common/tools/service/GenericRestServer.py b/src/common/tools/service/GenericRestServer.py index 51d3f828f..a5292e310 100644 --- a/src/common/tools/service/GenericRestServer.py +++ b/src/common/tools/service/GenericRestServer.py @@ -37,7 +37,8 @@ class GenericRestServer(threading.Thread): self.bind_port = bind_port self.base_url = base_url self.bind_address = get_http_bind_address() if bind_address is None else bind_address - self.endpoint = 'http://{:s}:{:s}{:s}'.format(str(self.bind_address), str(self.bind_port), str(self.base_url)) + self.endpoint = 'http://{:s}:{:s}'.format(str(self.bind_address), str(self.bind_port)) + if self.base_url is not None: self.endpoint += str(self.base_url) self.srv = None self.ctx = None self.app = Flask(__name__) -- GitLab