From 6ea4d8bb7e8d5a4985f514008e6aba820e06978c Mon Sep 17 00:00:00 2001 From: deel Date: Sat, 24 Feb 2024 02:04:44 +0100 Subject: [PATCH] fixing issue #7 regarding dependencies and coloring output --- iShutdown_detect.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/iShutdown_detect.py b/iShutdown_detect.py index 0bdaf73..64bdb58 100644 --- a/iShutdown_detect.py +++ b/iShutdown_detect.py @@ -6,16 +6,21 @@ import re import tarfile from datetime import datetime -from termcolor import colored def count_occurrences(content, target_phrase): return content.count(target_phrase) -def print_colored(text, color, blink=False): - attrs = ['blink'] if blink else None - print(colored(text, color, attrs=attrs)) +def print_colored(text, color): + if color == 'red': + print("\033[91m {}\033[00m" .format(text)) + elif color == 'yellow': + print("\033[93m {}\033[00m" .format(text)) + elif color == 'green': + print("\033[92m {}\033[00m" .format(text)) + else: + print(text) def find_anomalies_before_sigterm(content, anomaly_phrase, threshold=3):