From 6be1df5b6168019cad61b1fbe1a1d0d46d8b746a Mon Sep 17 00:00:00 2001 From: Johannes Nussbaum Date: Wed, 4 Oct 2023 20:03:53 +0200 Subject: [PATCH] add log statements to project.py --- dsp_permissions_scripts/utils/project.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dsp_permissions_scripts/utils/project.py b/dsp_permissions_scripts/utils/project.py index e60b8e67..25945444 100644 --- a/dsp_permissions_scripts/utils/project.py +++ b/dsp_permissions_scripts/utils/project.py @@ -4,9 +4,11 @@ from dsp_permissions_scripts.models.permission import Oap from dsp_permissions_scripts.utils.authentication import get_protocol -from dsp_permissions_scripts.utils.get_logger import get_timestamp +from dsp_permissions_scripts.utils.get_logger import get_logger, get_timestamp from dsp_permissions_scripts.utils.scope_serialization import create_scope_from_string +logger = get_logger(__name__) + def get_project_iri_by_shortcode(shortcode: str, host: str) -> str: """ @@ -51,6 +53,7 @@ def __get_all_resource_class_iris_of_project( host: str, token: str, ) -> list[str]: + logger.info(f"Getting all resource class IRIs of project {project_iri}...") project_onto_iris = __get_onto_iris_of_project( project_iri=project_iri, host=host, @@ -64,6 +67,7 @@ def __get_all_resource_class_iris_of_project( token=token, ) all_class_iris.extend(class_iris) + logger.info(f"Found {len(class_iris)} resource classes in onto {onto_iri}.") return all_class_iris @@ -111,12 +115,14 @@ def __get_all_resource_oaps_of_resclass( token: str, ) -> list[Oap]: print(f"{get_timestamp()}: Getting all resource OAPs of class {resclass_iri}...") + logger.info(f"Getting all resource OAPs of class {resclass_iri}...") protocol = get_protocol(host) headers = {"X-Knora-Accept-Project": project_iri, "Authorization": f"Bearer {token}"} resources: list[Oap] = [] page = 0 more = True while more: + logger.info(f"Getting page {page}...") more, iris = __get_next_page( protocol=protocol, host=host, @@ -126,6 +132,8 @@ def __get_all_resource_oaps_of_resclass( ) resources.extend(iris) page += 1 + print(f"{get_timestamp()}: Retrieved {len(resources)} resource OAPs of class {resclass_iri}.") + logger.info(f"Retrieved {len(resources)} resource OAPs of class {resclass_iri}.") return resources