Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/cli.py
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | def cook( | ||||
outfile: io.RawIOBase, | outfile: io.RawIOBase, | ||||
cooker_type: Optional[str], | cooker_type: Optional[str], | ||||
): | ): | ||||
""" | """ | ||||
Runs a vault cooker for a single object (identified by a SWHID), | Runs a vault cooker for a single object (identified by a SWHID), | ||||
and outputs it to the given file. | and outputs it to the given file. | ||||
""" | """ | ||||
from swh.core import config | from swh.core import config | ||||
from swh.objstorage.exc import ObjNotFoundError | |||||
from swh.objstorage.factory import get_objstorage | from swh.objstorage.factory import get_objstorage | ||||
from swh.storage import get_storage | from swh.storage import get_storage | ||||
from .cookers import COOKER_TYPES, get_cooker_cls | from .cookers import COOKER_TYPES, get_cooker_cls | ||||
from .in_memory_backend import InMemoryVaultBackend | from .in_memory_backend import InMemoryVaultBackend | ||||
conf = config.read(config_file) | conf = config.read(config_file) | ||||
Show All 40 Lines | cooker = cooker_cls( | ||||
obj_id=swhid.object_id, | obj_id=swhid.object_id, | ||||
backend=backend, | backend=backend, | ||||
storage=storage, | storage=storage, | ||||
graph=graph, | graph=graph, | ||||
objstorage=objstorage, | objstorage=objstorage, | ||||
) | ) | ||||
cooker.cook() | cooker.cook() | ||||
try: | |||||
bundle = backend.fetch(cooker_name, swhid.object_id) | bundle = backend.fetch(cooker_name, swhid.object_id) | ||||
assert bundle, "Cooker did not write a bundle to the backend." | except ObjNotFoundError: | ||||
bundle = None | |||||
if bundle is None: | |||||
raise click.ClickException("Cooker did not write a bundle to the backend.") | |||||
outfile.write(bundle) | outfile.write(bundle) | ||||
@vault.command(name="rpc-serve") | @vault.command(name="rpc-serve") | ||||
@click.option( | @click.option( | ||||
"--config-file", | "--config-file", | ||||
"-C", | "-C", | ||||
default=None, | default=None, | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |