From 9ba1c7554a749e7b3e8a2c75025f78a0241ed3b5 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Tue, 12 Dec 2023 20:39:08 +0200 Subject: [PATCH] Add the connection message. --- notification_client/MessagePrinter.py | 6 ++++++ notification_client/client.py | 1 + 2 files changed, 7 insertions(+) diff --git a/notification_client/MessagePrinter.py b/notification_client/MessagePrinter.py index a978aff..c149ece 100644 --- a/notification_client/MessagePrinter.py +++ b/notification_client/MessagePrinter.py @@ -2,6 +2,12 @@ from rich.console import Console from rich.markdown import Markdown class MessagePrinter: + @staticmethod + def connected(ip, port): + console = Console() + + console.print(f'[yellow b][INFO][/] Connected to the server ({ip}:{port}).') + @staticmethod def print(title: str, message: str): console = Console() diff --git a/notification_client/client.py b/notification_client/client.py index 9b7ded8..c548dfd 100644 --- a/notification_client/client.py +++ b/notification_client/client.py @@ -35,6 +35,7 @@ class Client: async def connect(self): try: reader, writer = await asyncio.open_connection(self.__ip, self.__port) + MessagePrinter.connected(self.__ip, self.__port) except ConnectionRefusedError: sys.stderr.write("Could not connect to the server. Please, check the ip and the port.\n") sys.exit(1)