def menu_principal(): print(Fore.BLUE + Style.BRIGHT + '\n ScriptMe / MySapache.py') print(Fore.GREEN + Style.BRIGHT + ' -----------------------') #SACAMOS INFORMACION SOBRE EL ESTADO DE APACHE print(Fore.CYAN + Style.BRIGHT + '\n 1)', end='') print(Fore.WHITE + Style.BRIGHT + ' Apache Options', end='') print(Fore.CYAN + Style.BRIGHT + ' (' + Fore.YELLOW + Style.BRIGHT + 'Status: ', end='') ruta_log = MS_clases.file_path() + '/log.txt' command = 'sudo systemctl status apache2 > ' + ruta_log comando(command) with open(ruta_log) as log: status_apache = log.readlines()[2] status_apache = status_apache.split(' ') if status_apache[6] == 'active': print(Fore.GREEN + Style.BRIGHT + '● ' + status_apache[6], end='') elif status_apache[6] == 'inactive': print(Fore.RED + Style.DIM + '● ' + status_apache[6], end='') else: print(Fore.RED + Style.DIM + 'Unknow') print(Fore.CYAN + Style.DIM + ')') #-----------------X---------------------- #SACAMOS INFORMACION SOBRE EL ESTADO DE MYSQL print(Fore.CYAN + Style.BRIGHT + '\n 2)', end='') print(Fore.WHITE + Style.BRIGHT + ' MySQL Options', end='') print(Fore.CYAN + Style.BRIGHT + ' (' + Fore.YELLOW + Style.BRIGHT + 'Status: ', end='') ruta_log = MS_clases.file_path() + '/log.txt' command = 'sudo systemctl status mysql > ' + ruta_log comando(command) with open(ruta_log) as log: status_apache = log.readlines()[2] status_apache = status_apache.split(' ') if status_apache[6] == 'active': print(Fore.GREEN + Style.BRIGHT + '● ' + status_apache[6], end='') elif status_apache[6] == 'inactive': print(Fore.RED + Style.DIM + '● ' + status_apache[6], end='') else: print(Fore.RED + Style.DIM + 'Unknow') print(Fore.CYAN + Style.DIM + ')') #-----------------X---------------------- print(Fore.CYAN + Style.BRIGHT + '\n 3)', end='') print(Fore.WHITE + Style.BRIGHT + ' OpenBrowser http//localhost.') print(Fore.CYAN + Style.BRIGHT + '\n 4)', end='') print(Fore.WHITE + Style.BRIGHT + ' Exit.') print(Fore.GREEN + Style.BRIGHT + '\n >> ', end="")
def browser_function(direccion): open_in_browser = 'brave-browser -new-window http://localhost/' + direccion + '> /dev/null 2>&1' #Con "> /dev/null 2>&1" ocultamos la salida del comando comando(open_in_browser)
def mysql_function(respuesta): if respuesta == 1: comando('clear') print(Fore.WHITE + Style.RESET_ALL + '\n') comando('sudo systemctl start mysql') elif respuesta == 2: comando('clear') print(Fore.WHITE + Style.RESET_ALL + '\n') comando('sudo systemctl stop mysql') elif respuesta == 3: comando('clear') print(Fore.WHITE + Style.RESET_ALL + '\n') comando('brave-browser -new-window http://localhost/phpmyadmin/' + '> /dev/null 2>&1')
def apache_function(respuesta): if respuesta == 1: comando('clear') print(Fore.WHITE + Style.RESET_ALL + '\n') comando('sudo systemctl start apache2') elif respuesta == 2: comando('clear') print(Fore.WHITE + Style.RESET_ALL + '\n') comando('sudo systemctl stop apache2') elif respuesta == 3: comando('clear') print(Fore.WHITE + Style.RESET_ALL + '\n') print(Fore.BLUE + Style.BRIGHT + '\n Recuerda cambiar la ruta en ambos archivos') sleep(2) path = config_path() comand_path = 'sudo nvim ' + path comando(comand_path) comand_config = 'nvim ' + file_path() + '/config.txt' comando(comand_config)
#!/usr/bin/python3 from os import system as comando from os import popen, getcwd, path from getpass import getuser #importando clases import MS_clases, MS_menu from colorama import Fore, Style, init init() comando('sudo echo "Ingresando contraseña"') comando('clear') MS_clases.comprobacion_archivos() repeticion = True while repeticion == True: comando('clear') MS_menu.menu_principal() try: respuesta = int(input()) except: print(Fore.LIGHTRED_EX + Style.BRIGHT + '\n ERROR: No puede ingresar un caracter...', end='') input('Presione ENTER') respuesta = 0 if respuesta == 1: apache_repeat = True while apache_repeat == True: comando('clear')