Skip to content

Commit

Permalink
make OAP printing easier
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Oct 17, 2023
1 parent 4704b14 commit 8ac5ad5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions dsp_permissions_scripts/oap/oap_get_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from dsp_permissions_scripts.models.value import ValueUpdate
from dsp_permissions_scripts.oap.oap_model import Oap
from dsp_permissions_scripts.utils.authentication import get_protocol
from dsp_permissions_scripts.utils.get_logger import get_logger, get_timestamp
from dsp_permissions_scripts.utils.get_logger import get_logger
from dsp_permissions_scripts.utils.scope_serialization import create_string_from_scope

logger = get_logger(__name__)
Expand Down Expand Up @@ -213,12 +213,12 @@ def apply_updated_oaps_on_server(
warnings.warn(f"There are no OAPs to update on {host}")
return
logger.info(f"******* Updating OAPs of {len(resource_oaps)} resources on {host} *******")
print(f"{get_timestamp()}: ******* Updating OAPs of {len(resource_oaps)} resources on {host} *******")
print(f"******* Updating OAPs of {len(resource_oaps)} resources on {host} *******")
failed_res_iris: list[str] = []
for index, resource_oap in enumerate(resource_oaps):
msg = f"Updating permissions of resource {index + 1}/{len(resource_oaps)}: {resource_oap.object_iri}..."
logger.info(f"====={msg}")
print(f"{get_timestamp()}: {msg}")
print(msg)
try:
_update_permissions_for_resource_and_values(
resource_iri=resource_oap.object_iri,
Expand Down
11 changes: 5 additions & 6 deletions dsp_permissions_scripts/utils/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dsp_permissions_scripts.models.api_error import ApiError
from dsp_permissions_scripts.oap.oap_model import Oap
from dsp_permissions_scripts.utils.authentication import get_protocol
from dsp_permissions_scripts.utils.get_logger import get_logger, get_timestamp
from dsp_permissions_scripts.utils.get_logger import get_logger
from dsp_permissions_scripts.utils.helpers import dereference_prefix
from dsp_permissions_scripts.utils.scope_serialization import create_scope_from_string

Expand Down Expand Up @@ -77,7 +77,6 @@ def _get_all_resource_oaps_of_resclass(
project_iri: str,
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}"}
Expand All @@ -100,8 +99,8 @@ def _get_all_resource_oaps_of_resclass(
logger.error(f"{err}\nStop getting more pages, return what has been retrieved so far.")
warnings.warn(f"{err.message}\nStop getting more pages, return what has been retrieved so far.")
more = False
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}.")
print(f"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 Expand Up @@ -162,7 +161,7 @@ def get_all_resource_oaps_of_project(
excluded_class_iris: Iterable[str] = (),
) -> list[Oap]:
logger.info(f"******* Getting all resource OAPs of project {shortcode} *******")
print(f"{get_timestamp()}: ******* Getting all resource OAPs of project {shortcode} *******")
print(f"******* Getting all resource OAPs of project {shortcode} *******")
project_iri = get_project_iri_by_shortcode(
shortcode=shortcode,
host=host,
Expand All @@ -183,5 +182,5 @@ def get_all_resource_oaps_of_project(
)
all_resource_oaps.extend(resource_oaps)
logger.info(f"Retrieved a TOTAL of {len(all_resource_oaps)} resource OAPs of project {shortcode}.")
print(f"{get_timestamp()}: Retrieved a TOTAL of {len(all_resource_oaps)} resource OAPs of project {shortcode}.")
print(f"Retrieved a TOTAL of {len(all_resource_oaps)} resource OAPs of project {shortcode}.")
return all_resource_oaps

0 comments on commit 8ac5ad5

Please sign in to comment.