Skip to content

Commit

Permalink
Remove getttext calls within log messages
Browse files Browse the repository at this point in the history
closes pulp#690
  • Loading branch information
lubosmj committed Apr 14, 2022
1 parent 5d26f6a commit ba98fa5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGES/690.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Log messages are now not being translated.
2 changes: 1 addition & 1 deletion pulp_container/app/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async def get_tag(self, request):
and tag.tagged_manifest.media_type not in accepted_media_types
):
log.warn(
_("OCI format found, but the client only accepts {accepted_media_types}.").format(
"OCI format found, but the client only accepts {accepted_media_types}.".format(
accepted_media_types=accepted_media_types
)
)
Expand Down
24 changes: 10 additions & 14 deletions pulp_container/app/tasks/sync_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,13 @@ async def run(self):
man_sig_dcs = await self.create_signatures(man_dc, signature_source)
if self.signed_only and not man_sig_dcs:
log.info(
_(
"The unsigned image {img_digest} which is a part of the "
"manifest list {ml_digest} (tagged as `{tag}`) can't be "
"synced due to a requirement to sync signed content only. "
"The whole manifest list is skipped.".format(
img_digest=man_dc.content.digest,
ml_digest=list_dc.content.digest,
tag=tag_name,
)
"The unsigned image {img_digest} which is a part of the "
"manifest list {ml_digest} (tagged as `{tag}`) can't be "
"synced due to a requirement to sync signed content only. "
"The whole manifest list is skipped.".format(
img_digest=man_dc.content.digest,
ml_digest=list_dc.content.digest,
tag=tag_name,
)
)
# do not pass down the pipeline a manifest list with unsigned
Expand Down Expand Up @@ -533,10 +531,8 @@ async def create_signatures(self, man_dc, signature_source):
except aiohttp.client_exceptions.ClientResponseError as exc:
if exc.status != 404:
log.info(
_(
"{} is not accessible, can't sync an image signature. "
"Error: {} {}".format(signature_url, exc.status, exc.message)
)
"{} is not accessible, can't sync an image signature. "
"Error: {} {}".format(signature_url, exc.status, exc.message)
)
# 404 is fine, it means there are no or no more signatures available
break
Expand Down Expand Up @@ -593,7 +589,7 @@ def _include_layer(self, layer):
layer_type = layer.get("mediaType", MEDIA_TYPE.REGULAR_BLOB)
is_foreign = layer_type in (MEDIA_TYPE.FOREIGN_BLOB, MEDIA_TYPE.FOREIGN_BLOB_OCI)
if is_foreign and foreign_excluded:
log.debug(_("Foreign Layer: %(d)s EXCLUDED"), dict(d=layer))
log.debug("Foreign Layer: %(d)s EXCLUDED", dict(d=layer))
return False
return True

Expand Down
2 changes: 1 addition & 1 deletion pulp_container/app/tasks/synchronize.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def synchronize(remote_pk, repository_pk, mirror, signed_only):
repository = ContainerRepository.objects.get(pk=repository_pk)
if not remote.url:
raise ValueError(_("A remote must have a url specified to synchronize."))
log.info(_("Synchronizing: repository={r} remote={p}").format(r=repository.name, p=remote.name))
log.info("Synchronizing: repository={r} remote={p}".format(r=repository.name, p=remote.name))
first_stage = ContainerFirstStage(remote, signed_only)
dv = ContainerDeclarativeVersion(first_stage, repository, mirror)
return dv.create()
Expand Down
16 changes: 5 additions & 11 deletions pulp_container/app/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from gettext import gettext as _

import gnupg
import json
import logging
Expand Down Expand Up @@ -73,10 +71,8 @@ def extract_data_from_signature(signature_raw, man_digest):
crypt_obj = gpg.decrypt(signature_raw)
if not crypt_obj.data:
log.info(
_(
"It is not possible to read the signed document, GPG error: {}".format(
crypt_obj.stderr
)
"It is not possible to read the signed document, GPG error: {}".format(
crypt_obj.stderr
)
)
return
Expand All @@ -85,10 +81,8 @@ def extract_data_from_signature(signature_raw, man_digest):
sig_json = json.loads(crypt_obj.data)
except Exception as exc:
log.info(
_(
"Signed document cannot be parsed to create a signature for {}."
" Error: {}".format(man_digest, str(exc))
)
"Signed document cannot be parsed to create a signature for {}."
" Error: {}".format(man_digest, str(exc))
)
return

Expand All @@ -97,7 +91,7 @@ def extract_data_from_signature(signature_raw, man_digest):
errors.append(error.message)

if errors:
log.info(_("The signature for {} is not synced due to: {}".format(man_digest, errors)))
log.info("The signature for {} is not synced due to: {}".format(man_digest, errors))
return

sig_json["signing_key_id"] = crypt_obj.key_id
Expand Down

0 comments on commit ba98fa5

Please sign in to comment.