Skip to content

ConsoleProtocol: Update Signatures to match ConsoleExpectMixin #1712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions labgrid/protocol/consoleprotocol.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import abc
from typing import Optional

from pexpect import EOF, TIMEOUT


class ConsoleProtocol(abc.ABC):
"""Abstract class for the ConsoleProtocol"""

@abc.abstractmethod
def read(self):
def read(self, size: int = 1, timeout: float = 0.0, max_size: Optional[int] = None):
"""
Read data from underlying port
"""
Expand All @@ -24,7 +27,11 @@ def sendline(self, line: str):
def sendcontrol(self, char: str):
raise NotImplementedError

def expect(self, pattern: str):
def expect(
self,
pattern: str | bytes | type[EOF] | type[TIMEOUT] | list[str | bytes | type[EOF] | type[TIMEOUT]],
timeout: float = -1,
):
raise NotImplementedError

class Client(abc.ABC):
Expand Down
Loading