diff --git a/pyinfra/config.py b/pyinfra/config.py index c613a49..5927171 100644 --- a/pyinfra/config.py +++ b/pyinfra/config.py @@ -1,11 +1,23 @@ """Implements a config object with dot-indexing syntax.""" - from envyaml import EnvYAML from pyinfra.locations import CONFIG_FILE +def make_art(): + return """ +______ _____ __ +| ___ \ |_ _| / _| +| |_/ / _ | | _ __ | |_ _ __ __ _ +| __/ | | || || '_ \| _| '__/ _` | +| | | |_| || || | | | | | | | (_| | +\_| \__, \___/_| |_|_| |_| \__,_| + __/ | + |___/ +""" + + def _get_item_and_maybe_make_dotindexable(container, item): ret = container[item] return DotIndexable(ret) if isinstance(ret, dict) else ret diff --git a/pyinfra/pyampq/connection/connection.py b/pyinfra/pyampq/connection/connection.py index 096325e..292f4ac 100644 --- a/pyinfra/pyampq/connection/connection.py +++ b/pyinfra/pyampq/connection/connection.py @@ -2,7 +2,6 @@ import abc class Connection(abc.ABC): - @abc.abstractmethod def establish(self): - pass \ No newline at end of file + pass diff --git a/pyinfra/pyampq/connection/mock_connection.py b/pyinfra/pyampq/connection/mock_connection.py index 9b03c4c..00e98d8 100644 --- a/pyinfra/pyampq/connection/mock_connection.py +++ b/pyinfra/pyampq/connection/mock_connection.py @@ -2,6 +2,5 @@ from pyampq.connection.connection import Connection class MockConnection(Connection): - def establish(self): pass diff --git a/pyinfra/pyampq/connection/pika_connection.py b/pyinfra/pyampq/connection/pika_connection.py index ab4413d..f1255ee 100644 --- a/pyinfra/pyampq/connection/pika_connection.py +++ b/pyinfra/pyampq/connection/pika_connection.py @@ -1,4 +1,3 @@ class PikaConnection: - def establish(self): - pass \ No newline at end of file + pass diff --git a/pyinfra/pyampq/queue_manager/pika_queue_manager.py b/pyinfra/pyampq/queue_manager/pika_queue_manager.py index 9736e1e..67cca7b 100644 --- a/pyinfra/pyampq/queue_manager/pika_queue_manager.py +++ b/pyinfra/pyampq/queue_manager/pika_queue_manager.py @@ -43,16 +43,9 @@ def monkey_patch_queue_handle(channel, queue) -> QueueHandle: def get_connection(): - credentials = pika.PlainCredentials( - username=CONFIG.rabbitmq.user, - password=CONFIG.rabbitmq.password - ) + credentials = pika.PlainCredentials(username=CONFIG.rabbitmq.user, password=CONFIG.rabbitmq.password) - kwargs = { - "host": CONFIG.rabbitmq.host, - "port": CONFIG.rabbitmq.port, - "credentials": credentials - } + kwargs = {"host": CONFIG.rabbitmq.host, "port": CONFIG.rabbitmq.port, "credentials": credentials} parameters = pika.ConnectionParameters(**kwargs) @@ -62,7 +55,6 @@ def get_connection(): class PikaQueueManager(QueueManager): - def __init__(self, input_queue, output_queue): super().__init__(input_queue, output_queue) connection = get_connection() diff --git a/pyinfra/pyampq/queue_manager/queue_manager.py b/pyinfra/pyampq/queue_manager/queue_manager.py index 50bf916..a8af9d3 100644 --- a/pyinfra/pyampq/queue_manager/queue_manager.py +++ b/pyinfra/pyampq/queue_manager/queue_manager.py @@ -2,7 +2,6 @@ import abc class QueueHandle: - def empty(self) -> bool: raise NotImplemented() @@ -11,7 +10,6 @@ class QueueHandle: class QueueManager(abc.ABC): - def __init__(self, input_queue, output_queue): self._input_queue = input_queue self._output_queue = output_queue diff --git a/pyinfra/test/queue_manager_mock.py b/pyinfra/test/queue_manager_mock.py index ba8a634..ae2fedf 100644 --- a/pyinfra/test/queue_manager_mock.py +++ b/pyinfra/test/queue_manager_mock.py @@ -10,7 +10,6 @@ def monkey_patch_queue_handle(queue) -> QueueHandle: class QueueManagerMock(QueueManager): - def __init__(self, input_queue, output_queue): super().__init__(QueueMock(), QueueMock()) diff --git a/pyinfra/test/unit_tests/consumer_test.py b/pyinfra/test/unit_tests/consumer_test.py index 4215042..6c9d344 100644 --- a/pyinfra/test/unit_tests/consumer_test.py +++ b/pyinfra/test/unit_tests/consumer_test.py @@ -27,6 +27,7 @@ def consumer(queue_manager, callback): # consumer.consume() # assert queue_manager.output_queue.empty() + def test_consuming_nonempty_input_queue_puts_messages_on_output_queue_in_fifo_order(consumer, queue_manager, callback): queue_manager.clear() queue_manager.publish_request(1) diff --git a/src/serve.py b/src/serve.py index a712f06..3490f9e 100644 --- a/src/serve.py +++ b/src/serve.py @@ -8,7 +8,7 @@ from pyinfra.callback import ( make_retry_callback, make_callback_for_output_queue, ) -from pyinfra.config import CONFIG +from pyinfra.config import CONFIG, make_art from pyinfra.consume import consume, ConsumerError from pyinfra.core import make_payload_processor, make_storage_data_loader, make_analyzer from pyinfra.flask import run_probing_webserver, set_up_probing_webserver @@ -49,6 +49,7 @@ def make_callback(): def main(): # TODO: implement meaningful checks + logging.info(make_art()) webserver = Process(target=run_probing_webserver, args=(set_up_probing_webserver(),)) logging.info("Starting webserver...") webserver.start()