Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/cli/task.py
Show All 12 Lines | |||||
import click | import click | ||||
from . import cli | from . import cli | ||||
if TYPE_CHECKING: | if TYPE_CHECKING: | ||||
import datetime | import datetime | ||||
# importing swh.storage.interface triggers the load of 300+ modules, so... | # importing swh.storage.interface triggers the load of 300+ modules, so... | ||||
from swh.model.model import Origin | import swh.model.model | ||||
from swh.storage.interface import StorageInterface | from swh.storage.interface import StorageInterface | ||||
locale.setlocale(locale.LC_ALL, "") | locale.setlocale(locale.LC_ALL, "") | ||||
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) | CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) | ||||
DATETIME = click.DateTime() | DATETIME = click.DateTime() | ||||
▲ Show 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | def schedule_task(ctx, type, options, policy, priority, next_run): | ||||
] | ] | ||||
for task in created: | for task in created: | ||||
output.append(pretty_print_task(task)) | output.append(pretty_print_task(task)) | ||||
click.echo("\n".join(output)) | click.echo("\n".join(output)) | ||||
def iter_origins( # use string annotations to prevent some pkg loading | def iter_origins( # use string annotations to prevent some pkg loading | ||||
storage: "StorageInterface", | storage: StorageInterface, | ||||
page_token: "Optional[str]" = None, | page_token: Optional[str] = None, | ||||
) -> "Iterator[Origin]": | ) -> Iterator[swh.model.model.Origin]: | ||||
"""Iterate over origins in the storage. Optionally starting from page_token. | """Iterate over origins in the storage. Optionally starting from page_token. | ||||
This logs regularly an info message during pagination with the page_token. This, in | This logs regularly an info message during pagination with the page_token. This, in | ||||
order to feed it back to the cli if the process interrupted. | order to feed it back to the cli if the process interrupted. | ||||
Yields | Yields | ||||
origin model objects from the storage | origin model objects from the storage | ||||
▲ Show 20 Lines • Show All 289 Lines • Show Last 20 Lines |