How to use the aria2p.interface.Interface function in aria2p

To help you get started, we’ve selected a few aria2p examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pawamoy / aria2p / tests / test_interface.py View on Github external
import time
from pathlib import Path

from asciimatics.event import KeyboardEvent, MouseEvent
from asciimatics.screen import Screen

from aria2p import interface as tui

from . import SESSIONS_DIR, Aria2Server

tui.Interface.frames = 20  # reduce tests time


class SpecialEvent:
    RESIZE = 1
    PASS_N_FRAMES = 2
    PASS_N_TICKS = 3
    RAISE = 4

    def __init__(self, event_type, value=None):
        self.type = event_type
        self.value = value


class Event:
    resize = SpecialEvent(SpecialEvent.RESIZE)
    pass_frame = SpecialEvent(SpecialEvent.PASS_N_FRAMES, 1)
github pawamoy / aria2p / tests / test_interface.py View on Github external
def get_interface(patcher, api=None, events=None, append_q=True):
    if not events:
        events = []

    if append_q:
        events.append(KeyboardEvent(ord("q")))

    class MockedManagedScreen:
        def __enter__(self):
            return MockedScreen(events)

        def __exit__(self, exc_type, exc_val, exc_tb):
            pass

    patcher.setattr(tui, "ManagedScreen", MockedManagedScreen)
    return tui.Interface(api=api)
github pawamoy / aria2p / tests / test_interface.py View on Github external
def test_mouse_event(monkeypatch):
    reverse = tui.Interface.reverse
    with Aria2Server(port=7608, session=SESSIONS_DIR / "3-magnets.txt") as server:
        interface = run_interface(
            monkeypatch,
            server.api,
            events=[MouseEvent(x=tui.Interface.x_offset, y=tui.Interface.y_offset, buttons=MouseEvent.LEFT_CLICK)] * 2,
        )
    assert interface.sort == 0
    assert interface.reverse is not reverse