Пример #1
0
def control():
    global borra
    borra_pantalla()
    print(
        Cursor.DOWN(2) + Cursor.FORWARD(10) + Style.BRIGHT + Fore.YELLOW +
        ">>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>> (Micro) Sistema de archivos <<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>>>>>>>> Realizado por: <<<<<<<<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>> FLORES GASPAR JUAN ANTONIO <<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>>>>>>>>>>>>>>> Y <<<<<<<<<<<<<<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>>>>>> CORTES BENITEZ YAIR <<<<<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<")
    while True:
        if (borra != 0):
            borra_pantalla()
        print(
            Cursor.DOWN(2) + Cursor.FORWARD(10) + Style.BRIGHT + Fore.BLUE +
            "********************* OPCIONES *******************\n")
        print(" lista                                => Lista archivos")
        print(
            " agrega <nombre de archivo> 'cadena'  => Agrega una cadena a un archivo"
        )
        print("  nuevo <nombre de archivo> 'cadena'  => Crea un archivo")
        print("  borra <nombre de archivo>           => Borra un archivo")
        print(
            "    ver <nombre de archivo>           => Muestra el contenido de un archivo"
        )
        print("  ayuda                               => AYUDA")
        print("  salir                               => SALIR\n")
        opc = input(Fore.GREEN + " ~ $$" + Style.RESET_ALL)
        if opc == "salir":
            break
        opcion(opc)
        borra += 1
Пример #2
0
def control():
    global semaforo_total, borra
    borra_pantalla()
    print(
        Cursor.DOWN(2) + Cursor.FORWARD(10) + Style.BRIGHT + Fore.YELLOW +
        ">>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>>>>>> MONITOR DE SISTEMA <<<<<<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>>>>>>>> Realizado por: <<<<<<<<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>> FLORES GASPAR JUAN ANTONIO <<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>>>>>>>>>>>>>>> Y <<<<<<<<<<<<<<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>>>>>> CORTES BENITEZ YAIR <<<<<<<<<<<<<<<")
    print(
        Cursor.FORWARD(10) +
        ">>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<")
    while True:
        if (borra != 0):
            borra_pantalla()
        print(
            Cursor.DOWN(2) + Cursor.FORWARD(10) + Style.BRIGHT + Fore.BLUE +
            "********************* OPCIONES *******************\n")
        print(" 1 => Información de Sistema")
        print(" 2 => Información de Discos")
        print(" 3 => Información de Procesos")
        print(" 4 => Información de Memoria")
        print(" 5 => Información de CPU")
        print(" 6 => Información de los buses PCI y los puertos USB")
        print(" 7 => Información de la tarjeta de Red")
        print(" 8 => Información de los sensores de la máquina")
        print(" 9 => Análisis general del sistema")
        print(" h => AYUDA")
        print(" 0 => SALIR\n")
        numero = input(Fore.GREEN + " ~ $$" + Style.RESET_ALL)
        if numero == "0":
            break
        opcion(numero)
        borra += 1
Пример #3
0
def menu_principal(opciones, titulo):
    os.system('cls')
    print(
        '-' * 40,
        Cursor.DOWN(1) + Cursor.BACK(41) +
        '{:15}{:29}{}'.format('|', Fore.BLUE + titulo, Style.RESET_ALL + '|'),
        Cursor.DOWN(1) + Cursor.BACK(41) + '-' * 40)
    for x in range(len(opciones)):
        print("{:3} {:5} {:29}|".format('|', str(x + 1) + ')', opciones[x]))
    print('-' * 40)
    mn = 3
    while mn != '1' and mn != '2' and mn != '3':
        mn = input('Elija Opcion [1/{}] '.format(len(opciones)))
    return mn
Пример #4
0
def Consultar(busca='', ban=0):
    result = ctr.consultar(busca)
    print('-' * 34,
          Cursor.DOWN(1) + Cursor.BACK(35) + '{:3}'.format('|'),
          Style.BRIGHT + Fore.BLUE + '{:15} {:12}'.format('ID', 'Grupo'),
          Style.RESET_ALL + '|',
          Cursor.DOWN(1) + Cursor.BACK(35) + ('-' * 34))
    for x in result:
        print('{:3} {:15} {:12} |'.format('|', str(x[0]), x[1]),
              Cursor.DOWN(1) + Cursor.BACK(35) + '-' * 34)
    if ban == 1:
        input(Cursor.DOWN(3) + 'Presione una tecla para continuar....: ')
        ban = 0
    else:
        ban = 0
Пример #5
0
def ayuda():
    borra_pantalla()
    print(
        Cursor.DOWN(5) + Cursor.FORWARD(5) + Back.BLUE + Fore.WHITE +
        "==================== AYUDA ===============\n\n" + Fore.WHITE)
    print(" lista => lista todos los archivos existentes")
    print(Cursor.FORWARD(5) + "Ejemplo: ~ $$lista ")
    print(" agrega => Agrega una cadena a un archivo")
    print(Cursor.FORWARD(5) + "Ejemplo: ~ $$agrega mi_archivo.txt 'Mi nombre'")
    print(
        Cursor.FORWARD(5) +
        "La cadena debe ir entre comillas simples si contiene algun espacio")
    print(" nuevo => Crea un archivo")
    print(Cursor.FORWARD(5) + "Ejemplo: ~ $$nuevo mi_archivo.txt 'Mi nombre'")
    print(
        Cursor.FORWARD(5) +
        "La cadena debe ir entre comillas simples si contiene algun espacio")
    print(" borra => Borra un archivo")
    print(Cursor.FORWARD(5) + "Ejemplo: ~ $$borra mi_archivo.txt")
    print(" ver => Muestra el contenido de un archivo")
    print(Cursor.FORWARD(5) + "Ejemplo: ~ $$ver mi_archivo.txt")
    print(
        Cursor.FORWARD(5) +
        "\nPara seleccionar una opción teclea el número correspondiente y presiona la tecla enter ;) "
    )
    espera = input("\npresiona enter para volver al menu... ")
    print(Style.RESET_ALL)
Пример #6
0
def MenuGrupo(opcion, titulo):
    os.system('cls')
    print(
        '-' * 41,
        Cursor.DOWN(1) + Cursor.BACK(42) +
        "{:14} {:33}".format('|', Style.BRIGHT + Fore.BLUE + titulo),
        Style.RESET_ALL + "|",
        Cursor.DOWN(1) + Cursor.BACK(42) + '-' * 41)
    for x in range(len(opcion)):
        print("{:3} {:5} {:30}|".format('|', str(x + 1) + ')', opcion[x]))
    print('-' * 41)
    while True:
        opc = int(input('ingrese opcion [1...{}]: '.format(len(opcion))))
        if 1 <= opc <= int(len(opcion)):
            break
    return opc
Пример #7
0
def eliminar():
    ing = validarNumeros(input(men[1]), men[1])
    gr = modGrupo(id=int(ing))
    if ctr.eliminar(gr):
        print('Registro eliminado exitosamente')
    else:
        print('error al eliminar registro')
    input(Cursor.DOWN(3) + 'Presione una tecla para continuar....: ')
Пример #8
0
def memoria():
    global semaforo_total
    semaforo_total.acquire()
    borra_pantalla()
    print(
        Cursor.DOWN(5) + Cursor.FORWARD(5) + Back.MAGENTA + Fore.WHITE +
        "================= INFORMACIÓN DE MEMORIA RAM ===============\n\n" +
        Style.RESET_ALL + Fore.MAGENTA)
    subprocess.run(["free", "-m"])
    sleep(5)
    borra_pantalla()
    print(
        Cursor.DOWN(5) + Cursor.FORWARD(5) + Back.MAGENTA + Fore.WHITE +
        "============ INFORMACIÓN GENERAL DE LA MEMORIA ==========\n\n" +
        Style.RESET_ALL + Fore.MAGENTA)
    subprocess.run(["cat", "/proc/meminfo"])
    sleep(5)
    semaforo_total.release()
Пример #9
0
def async_alert_str(*, terminal_columns: int, prompt: str, line: str,
                    cursor_offset: int, alert_msg: str) -> str:
    """Calculate the desired string, including ANSI escape codes, for displaying an asynchronous alert message.

    :param terminal_columns: terminal width (number of columns)
    :param prompt: prompt that is displayed on the current line
    :param line: current contents of the Readline line buffer
    :param cursor_offset: the offset of the current cursor position within line
    :param alert_msg: the message to display to the user
    :return: the correct string so that the alert message appears to the user to be printed above the current line.
    """
    from colorama import (
        Cursor, )

    # Split the prompt lines since it can contain newline characters.
    prompt_lines = prompt.splitlines()

    # Calculate how many terminal lines are taken up by all prompt lines except for the last one.
    # That will be included in the input lines calculations since that is where the cursor is.
    num_prompt_terminal_lines = 0
    for line in prompt_lines[:-1]:
        line_width = style_aware_wcswidth(line)
        num_prompt_terminal_lines += int(line_width / terminal_columns) + 1

    # Now calculate how many terminal lines are take up by the input
    last_prompt_line = prompt_lines[-1]
    last_prompt_line_width = style_aware_wcswidth(last_prompt_line)

    input_width = last_prompt_line_width + style_aware_wcswidth(line)

    num_input_terminal_lines = int(input_width / terminal_columns) + 1

    # Get the cursor's offset from the beginning of the first input line
    cursor_input_offset = last_prompt_line_width + cursor_offset

    # Calculate what input line the cursor is on
    cursor_input_line = int(cursor_input_offset / terminal_columns) + 1

    # Create a string that when printed will clear all input lines and display the alert
    terminal_str = ''

    # Move the cursor down to the last input line
    if cursor_input_line != num_input_terminal_lines:
        terminal_str += Cursor.DOWN(num_input_terminal_lines -
                                    cursor_input_line)

    # Clear each line from the bottom up so that the cursor ends up on the first prompt line
    total_lines = num_prompt_terminal_lines + num_input_terminal_lines
    terminal_str += (colorama.ansi.clear_line() +
                     Cursor.UP(1)) * (total_lines - 1)

    # Clear the first prompt line
    terminal_str += colorama.ansi.clear_line()

    # Move the cursor to the beginning of the first prompt line and print the alert
    terminal_str += '\r' + alert_msg
    return terminal_str
Пример #10
0
def modificar():
    id = validarNumeros(input(men[2]), men[2])
    des = validarLetra(input(men[0]), men[0])
    gr = modGrupo(id=id, des=des)
    if ctr.modificar(gr):
        print('Registro actualizado exitosamente')
    else:
        print('error al actualizar registro')
    input(Cursor.DOWN(3) + 'Presione una tecla para continuar....: ')
Пример #11
0
def buses_puertos():
    global semaforo_total
    semaforo_total.acquire()
    borra_pantalla()
    print(
        Cursor.DOWN(5) + Cursor.FORWARD(5) + Back.RED + Fore.WHITE +
        "============ INFORMACIÓN DE BUSES PCI ==========\n\n" +
        Style.RESET_ALL + Fore.YELLOW)
    subprocess.run("lspci", shell=True)
    sleep(5)
    borra_pantalla()
    print(
        Cursor.DOWN(5) + Cursor.FORWARD(5) + Back.RED + Fore.WHITE +
        "============ INFORMACIÓN DE PUERTOS USB ==========\n\n" +
        Style.RESET_ALL + Fore.YELLOW)
    subprocess.run("lsusb", shell=True)
    sleep(5)
    semaforo_total.release()
Пример #12
0
def insertar(rango):
    for paso in range(int(rango)):
        ing = validarLetra(input(men[0]), men[0])
        gr = modGrupo(id=0, des=ing)
        if ctr.insertar(gr):
            print('Registro Guardado exitosamente')
        else:
            print('error al insertar registro')
    input(Cursor.DOWN(3) + 'Presione una tecla para continuar....: ')
Пример #13
0
 def __print_bcp_table_at_moment(self):
     table_bcp = []
     print(Cursor.DOWN(16))
     generate_bcp_per_process(self.__queue_new_process,
                              self.__bloqued_process, self.__ready_process,
                              self.__listProcessFinish, table_bcp,
                              self.__countProgram - 1)
     for index in range(0, len(table_bcp)):
         print(table_bcp[index].print_counters_process())
Пример #14
0
def cpu():
    global semaforo_total
    semaforo_total.acquire()
    borra_pantalla()
    print(
        Cursor.DOWN(5) + Cursor.FORWARD(5) + Back.BLUE + Fore.WHITE +
        "============== INFORMACIÓN DE CPU ==========\n\n" + Style.RESET_ALL +
        Fore.BLUE)
    subprocess.run("lscpu", shell=True)
    sleep(5)
    semaforo_total.release()
Пример #15
0
def discos():
    global semaforo_total
    semaforo_total.acquire()
    borra_pantalla()
    print(
        Cursor.DOWN(5) + Cursor.FORWARD(5) + Back.GREEN + Fore.WHITE +
        "================= INFORMACIÓN DE DISCOS ==================\n\n" +
        Style.RESET_ALL + Fore.GREEN)
    subprocess.run(["df", "-h"])
    sleep(5)
    semaforo_total.release()
Пример #16
0
def sensores():
    global semaforo_total
    semaforo_total.acquire()
    borra_pantalla()
    print(
        Cursor.DOWN(5) + Cursor.FORWARD(5) + Back.MAGENTA + Fore.WHITE +
        "============ INFORMACIÓN DE LOS SENSORES ==========\n\n" +
        Style.RESET_ALL + Fore.MAGENTA)
    subprocess.run("sensors", shell=True)
    sleep(5)
    semaforo_total.release()
Пример #17
0
def red():
    global semaforo_total
    semaforo_total.acquire()
    borra_pantalla()
    print(
        Cursor.DOWN(5) + Cursor.FORWARD(5) + Back.GREEN + Fore.WHITE +
        "=========== INFORMACIÓN DE TARJETA(S) DE RED ==========\n\n" +
        Style.RESET_ALL + Fore.GREEN)
    subprocess.run("ifconfig", shell=True)
    sleep(5)
    semaforo_total.release()
Пример #18
0
def procesos():
    global semaforo_total
    semaforo_total.acquire()
    borra_pantalla()
    print(
        Cursor.DOWN(5) + Cursor.FORWARD(5) + Back.CYAN + Fore.WHITE +
        "=============== INFORMACIÓN DE PROCESOS ==========\n\n" +
        Style.RESET_ALL + Fore.CYAN)
    subprocess.run(["ps", "-e"])
    sleep(5)
    semaforo_total.release()
Пример #19
0
 def __printEnqueueBloquedProcess(self):
     print(Cursor.DOWN(2))
     self.__bloqued_process.print_queue()
     print("\r" + Fore.LIGHTYELLOW_EX + "Contador del programa: ",
           str(self.__countProgram),
           end="")
     print(Fore.RESET)
     print(Cursor.UP(15))
     self.__flag_unlock_process = is_time_bloqued_finish(
         self.__bloqued_process)
     calculate_bloqued_time(self.__bloqued_process)
     sleep(1)
Пример #20
0
def sistema():
    global semaforo_total
    semaforo_total.acquire()
    borra_pantalla()
    print(
        Cursor.DOWN(5) + Cursor.FORWARD(10) + Back.RED + Fore.WHITE +
        "================ INFORMACIÓN DE SISTEMA ==================" +
        Style.RESET_ALL)
    print(
        Cursor.FORWARD(10) + Cursor.DOWN(2) + Fore.RED + "Sistema : ",
        platform.system())
    print(Cursor.FORWARD(10) + "Arquitectura de: ", platform.architecture())
    print(Cursor.FORWARD(10) + "Máquina: ", platform.machine())
    print(Cursor.FORWARD(10) + "Procesador: ", platform.processor())
    print(Cursor.FORWARD(10) + "Red", platform.node())
    print(
        Cursor.FORWARD(10) + "Versión de sistema operativo: ",
        platform.version())
    print(
        Cursor.FORWARD(10) + "Versión de Python: ", platform.python_version())
    sleep(5)
    semaforo_total.release()
Пример #21
0
def ayuda():
    borra_pantalla()
    print(
        Cursor.DOWN(5) + Cursor.FORWARD(5) + Back.BLUE + Fore.WHITE +
        "==================== AYUDA ===============\n\n" + Fore.WHITE)
    print(" 1 => Información de Sistema")
    print(
        Cursor.FORWARD(5) +
        "información sobre arquitectura, procesador, red, tipo, etc del sistema"
    )
    print(" 2 => Información de Discos")
    print(
        Cursor.FORWARD(5) +
        "información sobre nombre, capacidad y montaje de discos del sistema")
    print(" 3 => Información de Procesos")
    print(
        Cursor.FORWARD(5) +
        "información sobre procesos en ejecución en el sistema")
    print(" 4 => Información de Memoria")
    print(
        Cursor.FORWARD(5) +
        "información sobre memoria RAM y memoria total del sistema")
    print(" 5 => Información de CPU")
    print(
        Cursor.FORWARD(5) +
        "información sobre arquitectura, numero, familia de la CPU del sistema"
    )
    print(" 6 => Información de los buses PCI y los puertos USB")
    print(
        Cursor.FORWARD(5) +
        "información sobre los buses PCI y los puertos USB del sistema")
    print(" 7 => Información de la tarjeta de Red")
    print(
        Cursor.FORWARD(5) +
        "información sobre ip, dirección MAC de las tarjetas de red del sistema"
    )
    print(" 8 => Información de los sensores de la máquina")
    print(Cursor.FORWARD(5) + "información sobre temperatura del sistema")
    print(" 9 => Análisis general del sistema")
    print(Cursor.FORWARD(5) + "Realiza todas las funciones anteriores")
    print(
        Cursor.FORWARD(5) +
        "\nPara seleccionar una opción teclea el número correspondiente y presiona la tecla enter ;) "
    )
    espera = input("\npresiona enter para volver al menu... ")
    print(Style.RESET_ALL)
Пример #22
0
 def __printProcessActual(self, process):
     maximunTime = 1
     idProgram = " "
     operation = " "
     timeRest = " "
     time = " "
     index = 1
     if process is not None:
         maximunTime = process.getMaximumTime()
         idProgram = process.getNumberProgram()
         operation = str(process.getFirstNumber()) + " " +\
                     process.getOperation() + " "+str(process.getSecondNumber())
         if process.getTimeTranscurred() > 0:
             index = process.getTimeTranscurred()
     print("\r" + Cursor.FORWARD(46) + "Operacion: " + operation, end="\n")
     print("\r" + Cursor.FORWARD(46) + "ID: " + str(idProgram), end="\n")
     while self.__flagToContinuePrintProcess:
         self.__interruption.listenInterruption()
         if index < maximunTime + 1:
             if process is not None:
                 timeRest = maximunTime - index
                 time = index
             print("\r" + Cursor.FORWARD(46) + "Tiempo transcurrido: " +
                   str(time) + "\n" + Cursor.FORWARD(46) +
                   "Tiempo restante: " + str(timeRest) + " ",
                   end="")
             if process is not None:
                 process.setTimeTranscurred(time)
             print(Cursor.DOWN(4))
             self.__countProgram += 1
             print("\r" + Fore.LIGHTYELLOW_EX + "Contador del programa: ",
                   str(self.__countProgram),
                   end="")
             print(Fore.RESET)
             print(Cursor.UP(8))
             self.__statusOfInterruptionInside()
             if idProgram is not 0:
                 sleep(1)
             else:
                 break
         else:
             break
         index = index + 1
Пример #23
0
print(Back.RESET, Cursor.UP(1) + '\n')
print(
    Fore.BLUE + Back.WHITE +
    "Searching: \"le meilleur alternant en Web Dev à Paris\"",
    emoji.emojize(':detective:'))

for i in range(12):
    sleep(0.3)
    print(Cursor.UP(1) + Cursor.FORWARD(55) + "." * i)

print("One Web Dev found!" + emoji.emojize(':man_technologist:'))
sleep(2)
print("Loading data....")
sleep(2)
print("Importing email: \"[email protected]\" ", emoji.emojize(':e-mail:'),
      emoji.emojize(':open_file_folder:') + '\n')
sleep(0.7)

for char in string_one:
    print(Fore.LIGHTGREEN_EX + Back.RESET + char, end="", flush=True)
    sleep(0.01)

sleep(2)
print("\nData loaded successfully!")
sleep(1)
for char in signature:
    print(Fore.BLUE + Back.WHITE + char, end="", flush=True)
    sleep(0.02)
print(Cursor.DOWN(1))
sleep(30)
Пример #24
0
from colorama import Cursor

up = lambda n=1: print(Cursor.UP(n), end="")
down = lambda n=1: print(Cursor.DOWN(n), end="")
left = lambda n=1: print(Cursor.BACK(n), end="")
right = lambda n=1: print(Cursor.FORWARD(n), end="")
pos = lambda x, y: print(Cursor.POS(x, y), end="")


class cursor:
    def __init__(self):
        pos(0, 0)
        self.x = 0
        self.y = 0

        self.saved_positions = {}

    def down(self, n=1):
        self.y += n
        pos(self.x, self.y)

    def up(self, n=1):
        self.y -= n
        pos(self.x, self.y)

    def right(self, n=1):
        self.x += n
        pos(self.x, self.y)

    def left(self, n=1):
        self.x -= n
Пример #25
0
 def down(self, count):
     self.print(Cursor.DOWN(count), end='')
Пример #26
0
 def print_table_bcp(self):
     print(Cursor.DOWN(17))
     print(Fore.YELLOW + "Tabla BCP")
     print(Fore.RESET)
     for index in range(0, len(self.__list)):
         print(self.__list[index].print_counters_process())
Пример #27
0
 def move_down(self, index):
     """ return char to move down to index and update current
     """
     diff = index - self.current
     self.current += diff
     return Cursor.DOWN(diff)
Пример #28
0
def down(n):
    return Cursor.DOWN(n)