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
Branches
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)
# Python Unified Device Interface
Current stable version: 9.3.6
Current stable version: 9.3.7
## Installation
1. Install the WZL-UDI package via pip
......@@ -58,6 +58,9 @@ Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation)
## Recent changes
**9.3.7** - 2024-03-18
- fixed serialization of semantics
**9.3.6** - 2024-03-18
- fixed serialization of semantic values
......
......@@ -4,7 +4,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setup(name='wzl-udi',
version='9.3.6',
version='9.3.7',
url='https://git-ce.rwth-aachen.de/wzl-mq-public/soil/python',
project_urls={
"Bug Tracker": "https://git-ce.rwth-aachen.de/wzl-mq-public/soil/python/-/issues",
......
......@@ -197,6 +197,7 @@ class HTTPServer(object):
resource_type = HTTPServer.analyze_request_url(request)
keys = self._filter_query(request.query)
try:
if resource_type == ResourceType.profile:
if self._profiles_path is None:
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):
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)
recursive = request.query is not None and 'all' in request.query
response = item.serialize_semantics(resource_type, recursive)
else:
assert resource_type == ResourceType.element
uuids = HTTPServer.parse_uuids(request)
......@@ -229,19 +232,18 @@ class HTTPServer(object):
try:
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:
logger.error(traceback.format_exc())
response = {'error': str(e)}
logger.error('Response: {}'.format(response))
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
logger.info('Response: {}'.format(response))
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