Skip to content

Commit

Permalink
tail -> tails and remove print statements
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Whitehead <[email protected]>
  • Loading branch information
andrewwhitehead committed Mar 4, 2020
1 parent ff07c71 commit 3be1d9b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Issuer revocation registry storage handling."""

import json
import logging
import uuid
from typing import Sequence

Expand All @@ -19,6 +20,8 @@

DEFAULT_REGISTRY_SIZE = 100

LOGGER = logging.getLogger(__name__)


class IssuerRevocationRecord(BaseRecord):
"""Class for managing local issuing revocation registries."""
Expand Down Expand Up @@ -125,7 +128,7 @@ async def generate_registry(self, context: InjectionContext, base_dir: str):
"default", tails_writer_config
)

print("create revocation registry with size:", self.max_cred_num)
LOGGER.debug("create revocation registry with size:", self.max_cred_num)

(
revoc_reg_id,
Expand Down
6 changes: 3 additions & 3 deletions aries_cloudagent/revocation/models/revocation_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async def create_tails_reader(self, context: InjectionContext) -> int:
tails_file_path = Path(self.get_receiving_tails_local_path(context))

if not tails_file_path.exists():
raise FileNotFoundError("Tail file does not exist.")
raise FileNotFoundError("Tails file does not exist.")

tails_reader_config = json.dumps(
{
Expand All @@ -142,7 +142,7 @@ async def create_tails_reader(self, context: InjectionContext) -> int:
return await indy.blob_storage.open_reader("default", tails_reader_config)

def get_receiving_tails_local_path(self, context: InjectionContext):
"""Make the local path to the tail file we download from remote URI."""
"""Make the local path to the tails file we download from remote URI."""
if self._tails_local_path:
return self._tails_local_path

Expand All @@ -159,7 +159,7 @@ def has_local_tails_file(self, context: InjectionContext) -> bool:
async def retrieve_tails(self, context: InjectionContext):
"""Fetch the tails file from the public URI."""
if not self._tails_public_uri:
raise RevocationError("Tail file public uri is empty")
raise RevocationError("Tails file public URI is empty")

try:
tails_stream = await fetch_stream(self._tails_public_uri)
Expand Down
28 changes: 17 additions & 11 deletions aries_cloudagent/revocation/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from aiohttp import web
from aiohttp_apispec import docs, request_schema, response_schema

import logging

from marshmallow import fields, Schema

from ..messaging.credential_definitions.util import CRED_DEF_SENT_RECORD_TYPE
Expand All @@ -16,6 +18,8 @@
from .models.issuer_revocation_record import IssuerRevocationRecordSchema
from .models.revocation_registry import RevocationRegistry

LOGGER = logging.getLogger(__name__)


class RevRegCreateRequestSchema(Schema):
"""Request schema for revocation registry creation request."""
Expand All @@ -34,10 +38,10 @@ class RevRegCreateResultSchema(Schema):


class RevRegUpdateTailFileUriSchema(Schema):
"""Request schema for updating tail file URI."""
"""Request schema for updating tails file URI."""

tails_public_uri = fields.Url(
description="Public URI to the tail file", required=True
description="Public URI to the tails file", required=True
)


Expand Down Expand Up @@ -118,20 +122,20 @@ async def get_current_registry(request: web.BaseRequest):

@docs(
tags=["revocation"],
summary="Get the tail file of revocation registry",
summary="Download the tails file of revocation registry",
produces="application/octet-stream",
parameters=[{"in": "path", "name": "id", "description": "revocation registry id."}],
responses={200: {"description": "tail file", "schema": {"type": "file"}}},
responses={200: {"description": "tails file", "schema": {"type": "file"}}},
)
async def get_tails_file(request: web.BaseRequest) -> web.FileResponse:
"""
Request handler for getting the tail file of the revocation registry.
Request handler for downloading the tails file of the revocation registry.
Args:
request: aiohttp request object
Returns:
The tail file in FileResponse
The tails file in FileResponse
"""
context = request.app["request_context"]
Expand Down Expand Up @@ -174,21 +178,23 @@ async def publish_registry(request: web.BaseRequest):
raise web.HTTPNotFound() from e

await revoc_registry.publish_registry_definition(context)
print("published registry definition")
LOGGER.debug("published registry definition: %s", registry_id)
await revoc_registry.publish_registry_entry(context)
print("published registry entry")
LOGGER.debug("published registry entry: %s", registry_id)

return web.json_response({"result": revoc_registry.serialize()})


@docs(
tags=["revocation"],
summary="Update revocation registry with new public URI to the tail file.",
summary="Update revocation registry with new public URI to the tails file.",
parameters=[
{
"in": "path",
"name": "id",
"description": "use credential definition id as the revocation registry id."
"description": (
"use credential definition id as the revocation registry id."
),
}
],
)
Expand Down Expand Up @@ -219,7 +225,7 @@ async def update_registry(request: web.BaseRequest):
raise web.HTTPNotFound() from e

revoc_registry.set_tails_file_public_uri(tails_public_uri)
await revoc_registry.save(context, reason="Updating tail file public URI.")
await revoc_registry.save(context, reason="Updating tails file public URI")

return web.json_response({"result": revoc_registry.serialize()})

Expand Down

0 comments on commit 3be1d9b

Please sign in to comment.