diff --git a/CHANGELOG.md b/CHANGELOG.md index e4ee1991ea606d0d88aee5bcd2b240fb4e51f57e..c9fc18824ac6e1641ff8997167666b5ee2e6a023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### -* Entity State support (experimental). See the `caosdb.State` class for more - information. +* Entity State support (experimental, no StateModel support yet). See the `caosdb.State` class for + more information. * Versioning support (experimental). ### Changed ### diff --git a/src/caosdb/common/administration.py b/src/caosdb/common/administration.py index 7997088a102e86cbf2daeb42a996a1b6ae57f446..e2846ef14d481ec938dd401289f8f0bbbfdc1d06 100644 --- a/src/caosdb/common/administration.py +++ b/src/caosdb/common/administration.py @@ -31,7 +31,7 @@ from lxml import etree from caosdb.common.utils import xml2str from caosdb.connection.connection import get_connection from caosdb.exceptions import (AuthorizationException, ClientErrorException, - EntityDoesNotExistError) + EntityDoesNotExistError, ServerConfigurationException) def set_server_property(key, value): @@ -52,9 +52,11 @@ def set_server_property(key, value): None """ con = get_connection() - - con._form_data_request(method="POST", path="_server_properties", - params={key: value}).read() + try: + con._form_data_request(method="POST", path="_server_properties", + params={key: value}).read() + except EntityDoesNotExistError: + raise ServerConfigurationException("Debug mode in server is probably disabled.") from None def get_server_properties(): @@ -68,7 +70,11 @@ def get_server_properties(): The server properties. """ con = get_connection() - body = con._http_request(method="GET", path="_server_properties").response + try: + body = con._http_request(method="GET", path="_server_properties").response + except EntityDoesNotExistError: + raise ServerConfigurationException("Debug mode in server is probably disabled.") from None + xml = etree.parse(body) props = dict() diff --git a/src/caosdb/common/state.py b/src/caosdb/common/state.py index de16c1ec5a64f093f5723b4db368f2de4b624e77..cb74022bef57a77c8270b2033c904eecabaadf83 100644 --- a/src/caosdb/common/state.py +++ b/src/caosdb/common/state.py @@ -1,3 +1,24 @@ +# ** header v3.0 +# This file is a part of the CaosDB Project. +# +# Copyright (C) 2020 IndiScale GmbH <info@indiscale.com> +# Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +# ** end header + import copy from lxml import etree diff --git a/src/caosdb/exceptions.py b/src/caosdb/exceptions.py index 5763bef4ac805a7dd1dfde8da2f6f3b7e5fd4bd8..c406ad9624f353a400a375314f5ce9bbbb8fe804 100644 --- a/src/caosdb/exceptions.py +++ b/src/caosdb/exceptions.py @@ -60,6 +60,13 @@ class ConfigurationException(CaosDBException): ".pycaosdb.ini. Do at least one of them exist and are they correct?") +class ServerConfigurationException(CaosDBException): + """The server is configured in a different way than expected. + + This can be for example unexpected flags or settings or missing extensions. + """ + + class ClientErrorException(CaosDBException): def __init__(self, msg, status, body): self.status = status