Skip to content

pause ¤

Command to pause downloads.

Functions:

  • pause

    Pause subcommand.

pause ¤

pause(
    api: API,
    gids: list[str] | None = None,
    do_all: bool = False,
    force: bool = False,
) -> int

Pause subcommand.

Parameters:

  • api (API) –

    The API instance to use.

  • gids (list[str] | None, default: None ) –

    The GIDs of the downloads to pause.

  • do_all (bool, default: False ) –

    Pause all downloads if True.

  • force (bool, default: False ) –

    Force pause or not (see API.pause).

Returns:

  • int ( int ) –

    0 if all success, 1 if one failure.

Source code in src/aria2p/cli/commands/pause.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def pause(
    api: API,
    gids: list[str] | None = None,
    do_all: bool = False,  # noqa: FBT001,FBT002
    force: bool = False,  # noqa: FBT001,FBT002
) -> int:
    """Pause subcommand.

    Parameters:
        api: The API instance to use.
        gids: The GIDs of the downloads to pause.
        do_all: Pause all downloads if True.
        force: Force pause or not (see API.pause).

    Returns:
        int: 0 if all success, 1 if one failure.
    """
    if do_all:
        if api.pause_all(force=force):
            return 0
        return 1

    try:
        downloads = api.get_downloads(gids)
    except ClientException as error:
        print(str(error), file=sys.stderr)
        return 1

    result = api.pause(downloads, force=force)

    if all(result):
        return 0

    for item in result:
        if isinstance(item, ClientException):
            print(item, file=sys.stderr)

    return 1