From 4584b3b0191baf3a9cd7f62d0a15f56a797a5d27 Mon Sep 17 00:00:00 2001 From: Picred <andry4you@hotmail.it> Date: Fri, 19 Apr 2024 14:08:11 +0200 Subject: [PATCH] feat: add python script template --- ingestion-manager.py | 28 +++++++++++++++++++++ test.py | 60 -------------------------------------------- 2 files changed, 28 insertions(+), 60 deletions(-) create mode 100644 ingestion-manager.py delete mode 100644 test.py diff --git a/ingestion-manager.py b/ingestion-manager.py new file mode 100644 index 0000000..02b89ed --- /dev/null +++ b/ingestion-manager.py @@ -0,0 +1,28 @@ +import asyncio +import time, socket + +def testLogstash(): + while True: + try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect(('logstash', 5000)) + sock.close() + print("[ingestion-manager]Logstash is ready!") + + break + except: + print("[ingestion-manager]Logstash not ready") + time.sleep(5) + continue + + +def main() -> None: + testLogstash() + + + +if __name__ == '__main__': + try: + asyncio.run(main()) + except KeyboardInterrupt: + print("[ingestion-manager]Program exited") diff --git a/test.py b/test.py deleted file mode 100644 index 562b4ae..0000000 --- a/test.py +++ /dev/null @@ -1,60 +0,0 @@ -# pylint: disable=missing-module-docstring, missing-function-docstring -import random - -def display_board(board): - for row in board: - print(" | ".join(row)) - print("-" * 9) - -def check_winner(board): - for row in board: - if row.count(row[0]) == len(row) and row[0] != " ": - return True - - for col in range(len(board[0])): - if board[0][col] == board[1][col] == board[2][col] and board[0][col] != " ": - return True - - if board[0][0] == board[1][1] == board[2][2] and board[0][0] != " ": - return True - - if board[0][2] == board[1][1] == board[2][0] and board[0][2] != " ": - return True - - return False - -def is_board_full(board): - for row in board: - if " " in row: - return False - return True - -def main(): - board = [[" " for _ in range(3)] for _ in range(3)] - players = ["X", "O"] - current_player = random.choice(players) - winner = False - - while not winner and not is_board_full(board): - display_board(board) - print(f"It's {current_player}'s turn") - row = int(input("Enter row (0, 1, or 2): ")) - col = int(input("Enter column (0, 1, or 2): ")) - - if board[row][col] == " ": - board[row][col] = current_player - if check_winner(board): - winner = current_player - else: - current_player = "O" if current_player == "X" else "X" - else: - print("That position is already taken!") - - display_board(board) - if winner: - print(f"{winner} wins!") - else: - print("It's a tie!") - -if __name__ == "__main__": - main()