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
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
try:
|
|
|
|
from colorama import init
|
|
|
|
from termcolor import colored
|
|
|
|
|
|
|
|
except ModuleNotFoundError as e:
|
2021-04-17 20:34:13 +00:00
|
|
|
logger.critical("Import Error: Unable to load {} module".format(e.name), exc_info=True)
|
|
|
|
print("Import Error: Unable to load {} module".format(e.name))
|
2021-01-19 13:56:00 +00:00
|
|
|
from app.classes.shared.installer import installer
|
|
|
|
installer.do_install()
|
|
|
|
sys.exit(1)
|
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")
|
|
|
|
self.magenta("[+] Crafty: {} - DEBUG:\t{}".format(dt, message))
|
|
|
|
|
|
|
|
def info(self, message):
|
|
|
|
dt = datetime.datetime.now().strftime("%Y-%m-%d %I:%M:%S %p")
|
|
|
|
self.white("[+] Crafty: {} - INFO:\t{}".format(dt, message))
|
|
|
|
|
|
|
|
def warning(self, message):
|
|
|
|
dt = datetime.datetime.now().strftime("%Y-%m-%d %I:%M:%S %p")
|
|
|
|
self.cyan("[+] Crafty: {} - WARNING:\t{}".format(dt, message))
|
|
|
|
|
|
|
|
def error(self, message):
|
|
|
|
dt = datetime.datetime.now().strftime("%Y-%m-%d %I:%M:%S %p")
|
|
|
|
self.yellow("[+] Crafty: {} - ERROR:\t{}".format(dt, message))
|
|
|
|
|
|
|
|
def critical(self, message):
|
|
|
|
dt = datetime.datetime.now().strftime("%Y-%m-%d %I:%M:%S %p")
|
|
|
|
self.red("[+] Crafty: {} - CRITICAL:\t{}".format(dt, message))
|
|
|
|
|
|
|
|
def help(self, message):
|
|
|
|
dt = datetime.datetime.now().strftime("%Y-%m-%d %I:%M:%S %p")
|
|
|
|
self.green("[+] Crafty: {} - HELP:\t{}".format(dt, message))
|
|
|
|
|
|
|
|
|
|
|
|
console = Console()
|
|
|
|
|