Exemple #1
0
def list_items(name: str, limit: int = 20):
    for i in FlowItem.iter_items(name, limit=limit):
        msg_parts = [
            f'  {i.worktime.strftime("%Y-%m-%dT%T").replace("T00:00:00", "")}  ',
            f"{i.status}  ",
            f"retries={i.retries}  ",
            f"duration={i.duration}  ",
            typer.style(f"log={i.info}", fg=typer.colors.WHITE)
            if i.info else "",
        ]

        if i.status in Statuses.error_statuses:
            msg_parts[1] = typer.style(msg_parts[1],
                                       fg=typer.colors.RED,
                                       bold=True)
        elif i.status == Statuses.add:
            msg_parts[1] = typer.style(msg_parts[1],
                                       fg=typer.colors.WHITE,
                                       bold=True)
        elif i.status == Statuses.run:
            msg_parts[1] = typer.style(msg_parts[1],
                                       fg=typer.colors.YELLOW,
                                       bold=True)
        elif i.status == Statuses.success:
            msg_parts[1] = typer.style(msg_parts[1],
                                       fg=typer.colors.GREEN,
                                       bold=True)

        typer.echo("".join(msg_parts))
Exemple #2
0
async def tasks_view(name: str, request: Request):
    # TODO: Add pagination
    return templates.TemplateResponse(
        "/pages/tasks.html",
        context={
            "request": request,
            "tasks": FlowItem.iter_items(name, limit=1000, offset=0),
        },
    )
Exemple #3
0
def test_local_executor():
    config = fakedata_to_csv_config.dict()
    config.pop("name")
    YamlHelper.iter_parse_file_from_dir = mock.Mock(
        return_value=(("test_local_executor", config), ))

    start_executor(orders=1, dry_run=True)

    items = list(FlowItem.iter_items("test_local_executor"))

    assert len(items) == 5
Exemple #4
0
def list_errors(name: str, limit: int = 1000):
    for i in FlowItem.iter_items(name, limit=limit):
        if i.status in Statuses.error_statuses:
            msg_parts = [
                f'  {i.worktime.strftime("%Y-%m-%dT%T").replace("T00:00:00", "")}  ',
                typer.style(f"{i.status}  ", fg=typer.colors.RED, bold=True),
                f"retries={i.retries}  ",
                f"duration={i.duration}  ",
                typer.style(f"log={i.info}", fg=typer.colors.WHITE)
                if i.info else "",
            ]

            typer.echo("".join(msg_parts))