[IMP] Print message with color

This commit is contained in:
2024-05-07 16:50:36 +02:00
parent 846d040d94
commit 628f540f67
+23 -2
View File
@@ -5,6 +5,7 @@ import jinja2
import os
import configparser
import sys
from colorama import Fore, Style
config = configparser.ConfigParser()
config.read('samba-pki-tools.ini')
@@ -15,6 +16,25 @@ config.read('samba-pki-tools.ini')
# template_variables = {
# "name": "TIS (%s)" % get_current_user(), }
class Printing():
def information(string):
print(Fore.CYAN + string)
return print(Style.RESET_ALL)
def success(string):
print(Fore.GREEN + string)
return print(Style.RESET_ALL)
def warning(string):
print(Fore.YELLOW + string)
return print(Style.RESET_ALL)
def error(string):
print(Fore.RED + string)
return print(Style.RESET_ALL)
class TisPKI:
def pki_dir():
@@ -138,11 +158,12 @@ def create_openssl_config():
gen_root_ca = subprocess.run(f'/usr/bin/openssl req -x509 -new -sha512 -config {root_ca_config} -days 3650 -extensions v3_ca -keyout {TisPKI.root_ca_keyfile()} -out {TisPKI.root_ca_certfile()}', shell=True, check=True, executable='/bin/bash')
if gen_root_ca.returncode == 0:
print(subprocess.run(f'openssl x509 -in {TisPKI.root_ca_certfile()} -text', shell=True, check=True, executable='/bin/bash'))
print(f'Root CA Certfile is stored in {TisPKI.root_ca_certfile()}')
subprocess.run(f'openssl x509 -in {TisPKI.root_ca_certfile()} -text', shell=True, check=True, executable='/bin/bash')
Printing.information(f'Root CA Certfile is stored in {TisPKI.root_ca_certfile()}')
input("Press Enter to continue...")
else:
print('Error on generating Root CA private key')
os.remove(TisPKI.root_ca_keyfile())
retry = input('If you want to retry, press Y')
if retry == "y" or retry == 'Y':
create_openssl_config()