Skip to content

Commit

Permalink
add log statements to project.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Oct 4, 2023
1 parent 9e02757 commit 6be1df5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dsp_permissions_scripts/utils/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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,
Expand All @@ -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


Expand Down Expand Up @@ -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,
Expand All @@ -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


Expand Down

0 comments on commit 6be1df5

Please sign in to comment.