Skip to content

stats ¤

This module defines the Stats class.

It holds information retrieved with the get_global_stat method of the client.

Classes:

  • Stats

    This class holds information retrieved with the get_global_stat method of the client.

Stats ¤

Stats(struct: dict)

This class holds information retrieved with the get_global_stat method of the client.

Parameters:

  • struct (dict) –

    A dictionary Python object returned by the JSON-RPC client.

Methods:

Attributes:

Source code in src/aria2p/stats.py
14
15
16
17
18
19
20
def __init__(self, struct: dict) -> None:
    """Initialize the object.

    Parameters:
        struct: A dictionary Python object returned by the JSON-RPC client.
    """
    self._struct = struct or {}

download_speed property ¤

download_speed: int

Overall download speed (byte/sec).

Returns:

  • int

    The overall download speed in bytes per second.

num_active property ¤

num_active: int

Return the number of active downloads.

Returns:

  • int

    The number of active downloads.

num_stopped property ¤

num_stopped: int

Return the number of stopped downloads in the current session.

This value is capped by the --max-download-result option.

Returns:

  • int

    The number of stopped downloads in the current session (capped).

num_stopped_total property ¤

num_stopped_total: int

Return the number of stopped downloads in the current session.

This value is not capped by the --max-download-result option.

Returns:

  • int

    The number of stopped downloads in the current session (not capped).

num_waiting property ¤

num_waiting: int

Return the number of waiting downloads.

Returns:

  • int

    The number of waiting downloads.

upload_speed property ¤

upload_speed: int

Overall upload speed (byte/sec).

Returns:

  • int

    The overall upload speed in bytes per second.

download_speed_string ¤

download_speed_string(human_readable: bool = True) -> str

Return the download speed as string.

Parameters:

  • human_readable (bool, default: True ) –

    Return in human readable format or not.

Returns:

  • str

    The download speed string.

Source code in src/aria2p/stats.py
31
32
33
34
35
36
37
38
39
40
41
42
def download_speed_string(self, human_readable: bool = True) -> str:  # noqa: FBT001,FBT002
    """Return the download speed as string.

    Parameters:
        human_readable: Return in human readable format or not.

    Returns:
        The download speed string.
    """
    if human_readable:
        return human_readable_bytes(self.download_speed, delim=" ", postfix="/s")
    return str(self.download_speed) + " B/s"

upload_speed_string ¤

upload_speed_string(human_readable: bool = True) -> str

Return the upload speed as string.

Parameters:

  • human_readable (bool, default: True ) –

    Return in human readable format or not.

Returns:

  • str

    The upload speed string.

Source code in src/aria2p/stats.py
53
54
55
56
57
58
59
60
61
62
63
64
def upload_speed_string(self, human_readable: bool = True) -> str:  # noqa: FBT001,FBT002
    """Return the upload speed as string.

    Parameters:
        human_readable: Return in human readable format or not.

    Returns:
        The upload speed string.
    """
    if human_readable:
        return human_readable_bytes(self.upload_speed, delim=" ", postfix="/s")
    return str(self.upload_speed) + " B/s"