flopz.listener package
Subpackages
Submodules
flopz.listener.event module
- class Event(data=None, flopz_config=None)
Bases:
object
A base class for all events that we can receive from targets
- Parameters
data (
Optional
[dict
]) –flopz_config (
Optional
[dict
]) –
- enter()
Interactive events will be ‘entered’ During enter(), the event takes over control and only returns when the event has been dealt with. Override this for interactive events. :return:
- is_interactive()
Events can be interactive or non-interactive. :rtype:
bool
:return: True, if this event requires interaction, False otherwise
- pretty_print()
used for logging this event to a text string :rtype:
str
:return: a pretty-printed string
- pretty_print_logger(logger, level)
used for logging to the console or standard log files :type logger:
Logger
:param logger: a logging.Logger :return: nothing
flopz.listener.flopz_logger module
- class FlopzLogger(flopz_config, args=None)
Bases:
object
A base class which handles logging events.
- Parameters
flopz_config (
dict
) –args (
Optional
[Namespace
]) –
- close()
called before the program exits. close file handles etc.
- flush()
Ensures that all data is written, f.ex. when logging to a file or socket
- log(event)
logs a single event :type event:
Event
:param event: the event to log :rtype:None
:return: nothing
- static name()
- Return type
str
- Returns
a unique name for this logger class
flopz.listener.link module
- class Link(flopz_config, arg_parser)
Bases:
object
Link implements receiving and sending data over a physical or networked connection to the target.
- Parameters
flopz_config (
dict
) –arg_parser (
Namespace
) –
- static add_argparse(parser)
Add a Link-specific argument group and arguments :type parser:
ArgumentParser
:param parser: :return: nothing
- get()
Ideally, this is a non-blocking call that returns received data or an empty byte string :rtype:
bytes
:return: a (potentially incomplete) chunk of received bytes
- static name()
override this to return a unique name for your link :rtype:
str
:return: a string containing a unique name for this link class
- put(payload)
Send data over the link :type payload:
bytes
:param payload: which data to send :rtype:int
:return: the number of bytes written
- start()
A non-blocking call that tells the Link to start listening and sending. Once the link has been started, it is ready to be used. :rtype:
None
:return: nothing
- stop()
A non-blocking call that tells the Link to stop Note that only when ‘state’ != RUNNING, the link can be considered fully stopped. :rtype:
None
:return: nothing
flopz.listener.protocol module
- class Protocol(config, link)
Bases:
object
A base class for (wire) protocols that a target can implement. Protocols are used to interpret the data we receive over a link. Likewise, it can be used to encode data that we send to the target. A target can implement its own protocol or use a generic protocol.
- Parameters
config (
dict
) –link (
Link
) –
- feed(data)
Consume a (potentially incomplete) chunk of bytes Generates events internally, as data comes in After calling this, you can check if events are available using has_events() :type data:
bytes
:param data:
- has_events()
- Return type
bool