zyklon

simple python monitoring / alert script
git clone git://shroom.party/zyklon.git
Log | Files | Refs | README | LICENSE

commit 113c71450e26741e82431a7bf77228f18b3b44f5
parent 59d884c60bff7d9dd43357561481e8a2af50075a
Author: tx <trqx@goat.si>
Date:   Thu, 20 Dec 2018 00:08:35 +0100

simplify color handling

Diffstat:
Mzyklon | 21+++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/zyklon b/zyklon @@ -7,15 +7,19 @@ import subprocess import sys import time -global_colors = False - # attempt to use colors try: - from colorama import Fore, Back, Style + from colorama import Fore - global_colors = True + RED = Fore.RED + RESET = Fore.RESET except: - pass + RED = "" + RESET = "" + + +def error(s): + sys.stderr.write(f"{RED}s{RESET}\n") class Alert: @@ -165,13 +169,6 @@ class Probe: return -def error(s): - if global_colors: - sys.stderr.write(Fore.RED + s + Fore.RESET + "\n") - else: - sys.stderr.write(s + "\n") - - # parse args parser = argparse.ArgumentParser(description="execute alerts") parser.add_argument("-d", "--directory", help="directory path", default=None)