Skip to content
Snippets Groups Projects
Commit 26a3ad59 authored by Matthias Stefan Bodenbenner's avatar Matthias Stefan Bodenbenner
Browse files

fixed serialization of semantics

parent 31d937e4
No related branches found
No related tags found
No related merge requests found
Pipeline #375564 passed
[![Build](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/lava/unified-device-interface/python/badges/master/pipeline.svg)](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/lava/unified-device-interface/python/commits/master) [![Build](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/lava/unified-device-interface/python/badges/master/pipeline.svg)](https://git-ce.rwth-aachen.de/wzl-mq-ms/forschung-lehre/lava/unified-device-interface/python/commits/master)
# Python Unified Device Interface # Python Unified Device Interface
Current stable version: 9.3.6 Current stable version: 9.3.7
## Installation ## Installation
1. Install the WZL-UDI package via pip 1. Install the WZL-UDI package via pip
...@@ -58,6 +58,9 @@ Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) ...@@ -58,6 +58,9 @@ Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation)
## Recent changes ## Recent changes
**9.3.7** - 2024-03-18
- fixed serialization of semantics
**9.3.6** - 2024-03-18 **9.3.6** - 2024-03-18
- fixed serialization of semantic values - fixed serialization of semantic values
......
...@@ -4,7 +4,7 @@ with open("README.md", "r", encoding="utf-8") as fh: ...@@ -4,7 +4,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read() long_description = fh.read()
setup(name='wzl-udi', setup(name='wzl-udi',
version='9.3.6', version='9.3.7',
url='https://git-ce.rwth-aachen.de/wzl-mq-public/soil/python', url='https://git-ce.rwth-aachen.de/wzl-mq-public/soil/python',
project_urls={ project_urls={
"Bug Tracker": "https://git-ce.rwth-aachen.de/wzl-mq-public/soil/python/-/issues", "Bug Tracker": "https://git-ce.rwth-aachen.de/wzl-mq-public/soil/python/-/issues",
......
...@@ -197,6 +197,7 @@ class HTTPServer(object): ...@@ -197,6 +197,7 @@ class HTTPServer(object):
resource_type = HTTPServer.analyze_request_url(request) resource_type = HTTPServer.analyze_request_url(request)
keys = self._filter_query(request.query) keys = self._filter_query(request.query)
try:
if resource_type == ResourceType.profile: if resource_type == ResourceType.profile:
if self._profiles_path is None: if self._profiles_path is None:
raise UserException('Can\'t return requested metadata profile, as no profiles have been created for this sensor service.') raise UserException('Can\'t return requested metadata profile, as no profiles have been created for this sensor service.')
...@@ -219,6 +220,8 @@ class HTTPServer(object): ...@@ -219,6 +220,8 @@ class HTTPServer(object):
semantic_name = request.url.parts[-2] if request.url.parts[-1] == '' else request.url.parts[-1] semantic_name = request.url.parts[-2] if request.url.parts[-1] == '' else request.url.parts[-1]
item, resource_type = self.root.resolve_semantic_path(semantic_name) item, resource_type = self.root.resolve_semantic_path(semantic_name)
recursive = request.query is not None and 'all' in request.query
response = item.serialize_semantics(resource_type, recursive)
else: else:
assert resource_type == ResourceType.element assert resource_type == ResourceType.element
uuids = HTTPServer.parse_uuids(request) uuids = HTTPServer.parse_uuids(request)
...@@ -229,19 +232,18 @@ class HTTPServer(object): ...@@ -229,19 +232,18 @@ class HTTPServer(object):
try: try:
item = self.root[uuids] item = self.root[uuids]
if resource_type.is_semantic():
recursive = request.query is not None and 'all' in request.query
response = item.serialize_semantics(resource_type, recursive)
else:
response = item.serialize(keys, self._legacy_mode, HTTP_GET)
except KeyError as e: except KeyError as e:
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
response = {'error': str(e)} response = {'error': str(e)}
logger.error('Response: {}'.format(response)) logger.error('Response: {}'.format(response))
return self.prepare_response(response, None, status=404, query=request.query) return self.prepare_response(response, None, status=404, query=request.query)
# serializing the element
try:
if resource_type.is_semantic() and resource_type != ResourceType.profile:
recursive = request.query is not None and 'all' in request.query
response = item.serialize_semantics(resource_type, recursive)
elif resource_type == ResourceType.element:
response = item.serialize(keys, self._legacy_mode, HTTP_GET)
status = 200 status = 200
logger.info('Response: {}'.format(response)) logger.info('Response: {}'.format(response))
except (DeviceException, ServerException, UserException) as e: except (DeviceException, ServerException, UserException) as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment