2020-08-12 00:36:09 +00:00
|
|
|
import datetime
|
|
|
|
import logging
|
2021-01-19 13:56:00 +00:00
|
|
|
import sys
|
2020-08-12 00:36:09 +00:00
|
|
|
|
2022-03-08 05:44:26 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
2020-08-12 00:36:09 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
from colorama import init
|
|
|
|
from termcolor import colored
|
|
|
|
|
2022-03-08 05:44:26 +00:00
|
|
|
except ModuleNotFoundError as ex:
|
|
|
|
logger.critical(f"Import Error: Unable to load {ex.name} module", exc_info=True)
|
|
|
|
print(f"Import Error: Unable to load {ex.name} module")
|
|
|
|
from app.classes.shared.installer import installer
|
|
|
|
installer.do_install()
|
2020-08-12 00:36:09 +00:00
|
|
|
class Console:
|
|
|
|
|
|
|
|
def __init__(self):
|
2021-01-19 13:56:00 +00:00
|
|
|
if 'colorama' in sys.modules:
|
2020-08-12 00:36:09 +00:00
|
|
|
init()
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def do_print(message, color):
|
2021-01-19 13:56:00 +00:00
|
|
|
if 'termcolor' in sys.modules or 'colorama' in sys.modules:
|
2020-08-12 00:36:09 +00:00
|
|
|
print(colored(message, color))
|
|
|
|
else:
|
|
|
|
print(message)
|
|
|
|
|
|
|
|
def magenta(self, message):
|
|
|
|
self.do_print(message, "magenta")
|
|
|
|
|
|
|
|
def cyan(self, message):
|
|
|
|
self.do_print(message, "cyan")
|
|
|
|
|
|
|
|
def yellow(self, message):
|
|
|
|
self.do_print(message, "yellow")
|
|
|
|
|
|
|
|
def red(self, message):
|
|
|
|
self.do_print(message, "red")
|
|
|
|
|
|
|
|
def green(self, message):
|
|
|
|
self.do_print(message, "green")
|
|
|
|
|
|
|
|
def white(self, message):
|
|
|
|
self.do_print(message, "white")
|
|
|
|
|
|
|
|
def debug(self, message):
|
|
|
|
dt = datetime.datetime.now().strftime("%Y-%m-%d %I:%M:%S %p")
|
2022-01-26 01:45:30 +00:00
|
|
|
self.magenta(f"[+] Crafty: {dt} - DEBUG:\t{message}")
|
2020-08-12 00:36:09 +00:00
|
|
|
|
|
|
|
def info(self, message):
|
|
|
|
dt = datetime.datetime.now().strftime("%Y-%m-%d %I:%M:%S %p")
|
2022-01-26 01:45:30 +00:00
|
|
|
self.white(f"[+] Crafty: {dt} - INFO:\t{message}")
|
2020-08-12 00:36:09 +00:00
|
|
|
|
|
|
|
def warning(self, message):
|
|
|
|
dt = datetime.datetime.now().strftime("%Y-%m-%d %I:%M:%S %p")
|
2022-01-26 01:45:30 +00:00
|
|
|
self.cyan(f"[+] Crafty: {dt} - WARNING:\t{message}")
|
2020-08-12 00:36:09 +00:00
|
|
|
|
|
|
|
def error(self, message):
|
|
|
|
dt = datetime.datetime.now().strftime("%Y-%m-%d %I:%M:%S %p")
|
2022-01-26 01:45:30 +00:00
|
|
|
self.yellow(f"[+] Crafty: {dt} - ERROR:\t{message}")
|
2020-08-12 00:36:09 +00:00
|
|
|
|
|
|
|
def critical(self, message):
|
|
|
|
dt = datetime.datetime.now().strftime("%Y-%m-%d %I:%M:%S %p")
|
2022-01-26 01:45:30 +00:00
|
|
|
self.red(f"[+] Crafty: {dt} - CRITICAL:\t{message}")
|
2020-08-12 00:36:09 +00:00
|
|
|
|
|
|
|
def help(self, message):
|
|
|
|
dt = datetime.datetime.now().strftime("%Y-%m-%d %I:%M:%S %p")
|
2022-01-26 01:45:30 +00:00
|
|
|
self.green(f"[+] Crafty: {dt} - HELP:\t{message}")
|
2020-08-12 00:36:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
console = Console()
|