def required(provider): """Shows the required attributes of a provider. Example: notifiers required pushover """ p = get_notifier(provider) click.echo(', '.join(p.required))
def metadata(provider): """Shows the provider's metadata. Example: notifiers metadata pushover """ p = get_notifier(provider) for k, v in p.metadata.items(): click.echo(f'{k}: {v}')
def provider(request): name = getattr(request.module, 'provider', None) if not name: pytest.fail( f"Test class '{request.module}' has not 'provider' attribute set") p = get_notifier(name) if not p: pytest.fail(f"No notifier with name '{name}'") return p
def defaults(provider): """Shows the provider's defaults. Example: notifiers defaults pushover """ p = get_notifier(provider) if not p.defaults: click.echo(f'{provider} has no defaults set') for k, v in p.defaults.items(): click.echo(f'{k}: {v}')
def arguments(provider): """Shows the name and schema of all the attributes of a provider. Example: notifiers arguments pushover """ p = get_notifier(provider) for name, schema in p.arguments.items(): click.echo(f'Name: \'{name}\', Schema: {schema}') click.echo(', '.join(p.required))
def notify(ctx, provider): """Send a notification to a passed provider. Data should be passed via a key=value input like so: notifiers notify pushover token=foo user=bar message=test """ p = get_notifier(provider) data = {} for item in ctx.args: data.update([item.split('=')]) if 'message' not in data: message = click.get_text_stream('stdin').read() if not message: raise click.ClickException( '\'message\' option is required. ' 'Either pass it explicitly or pipe into the command') data['message'] = message rsp = p.notify(**data) rsp.raise_on_errors()
_latest_block_based_cache_middleware, _simple_cache_middleware, ) from web3.middleware.exception_retry_request import exception_retry_middleware from web3.middleware.exception_retry_request import http_retry_request_middleware from web3.middleware.filter import local_filter_middleware from web3.middleware.geth_poa import geth_poa_middleware from web3.middleware.signing import construct_sign_and_send_raw_middleware from web3.middleware.stalecheck import make_stalecheck_middleware from web3.types import RPCEndpoint, Wei from websockets import ConnectionClosedError from proto.eth.v1alpha1.beacon_chain_pb2_grpc import BeaconChainStub # type: ignore # noqa: E501 from proto.eth.v1alpha1.validator_pb2_grpc import BeaconNodeValidatorStub # type: ignore # noqa: E501 telegram = get_notifier("telegram") class InterruptHandler: """ Tracks SIGINT and SIGTERM signals. https://stackoverflow.com/a/31464349 """ exit = False def __init__(self) -> None: signal.signal(signal.SIGINT, self.exit_gracefully) signal.signal(signal.SIGTERM, self.exit_gracefully) def exit_gracefully(self, signum: int, frame: Any) -> None:
def __post_init__(self): for k, v in self.__config.items(): if "message" in v: raise XValueError(f"Do not include message in defaults") get_notifier(provider_name=k, strict=True) # test