teatime.plugins package

Submodules

teatime.plugins.base module

This module holds the base plugin class and exception.

class teatime.plugins.base.BasePlugin[source]

Bases: abc.ABC

The base plugin class.

INTRUSIVE = True
run(context: teatime.plugins.context.Context)[source]

The plugin’s entrypoint as invoked by the scanner.

This method will call the plugin’s _check method, which should be overridden by concrete JSONRPCPlugin instances. It will catch any PluginException and skip the execution. In any case, at the end of the check run, the plugin name is added as a meta field to denote that it has been executed.

Parameters:context – The context object containing report-related information
class teatime.plugins.base.IPFSRPCPlugin[source]

Bases: teatime.plugins.base.BasePlugin, abc.ABC

static get_rpc_json(target: str, route: str = '', params: Union[dict, Sequence[tuple]] = None, headers: Optional[dict] = None, files: Optional[dict] = None, raw: bool = False, timeout: int = 3, stream_limit: int = None)[source]

Send a request to the IPFS HTTP API.

Parameters:
  • target – The target to send the request to
  • route – The URL to send the API request to
  • params – A dict of URL parameters to add
  • headers – Optional headers to attach
  • files – A dictionary of files to upload
  • raw – If true, the result will not interpreted as JSON
  • timeout – Number of seconds to wait until timing out
  • stream_limit – Maximum number of lines to read
Returns:

class teatime.plugins.base.JSONRPCPlugin[source]

Bases: teatime.plugins.base.BasePlugin, abc.ABC

A base plugin for JSON-RPC APIs.

static get_rpc_int(target, method, params: List[str] = None, idx: int = 1) → int[source]

Attempt to make an RPC call and decode the result as an integer.

Parameters:
  • target – The RPC target URL
  • method – The RPC method
  • params – Additional RPC method params (optional)
  • idx – RPC call index (optional)
Returns:

The payload result as integer

Raises:

PluginException – If connection or payload-related errors occur

static get_rpc_json(target: str, method: str, params: List[Union[str, int]] = None, idx: int = 0)[source]

Execute an RPC call against a given target.

The current timeout for the RPC request is three seconds. Any PluginException instances raised, contain the reason in the message string, e.g. if a connection failure occurred, the response status code was not 200, an error field is present, or if the result field is left empty.

Parameters:
  • target – The target URI to send the request to
  • method – The RPC method to use
  • params – Additional parameters for the method (optional)
  • idx – The RPC call’s ID (optional)
Returns:

The response payload’s “result” field

Raises:

PluginException – If the request faied or the response is inconsistent

exception teatime.plugins.base.PluginException[source]

Bases: Exception

An exception for plugin-related errors.

teatime.plugins.base.handle_connection_errors(func)[source]

Catch connection-related excetions and reraise.

This slim wrapper will catch connection and decoding errors, and requests-related exceptions to reraise them as PluginErrors so we can catch them in a standardized way.

teatime.plugins.context module

This module contains the context that is passed to plugins.

class teatime.plugins.context.Context(target, report, node_type, **kwargs)[source]

Bases: object

The context object passed between plugins.

class teatime.plugins.context.NodeType[source]

Bases: enum.Enum

An Enum denoting a node type to scan.

Currently, only Geth and Parity/OpenEthereum are supported. Future considerations are: - IPFS - Filecoin - ETH2 clients

GETH = 0
IPFS = 2
PARITY = 1

Module contents

The package holding all Teatime plugins.