add initial scripts for backup and system resource management
This commit is contained in:
parent
4097adef18
commit
7df8a79e99
|
|
@ -0,0 +1,5 @@
|
||||||
|
"""
|
||||||
|
hay que crear el script de backup
|
||||||
|
ver el sistema operativo
|
||||||
|
ejecutar el script segun SO
|
||||||
|
"""
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
import subprocess
|
||||||
|
import platform
|
||||||
|
|
||||||
|
|
||||||
|
def abrir_vscode():
|
||||||
|
"""
|
||||||
|
Intenta abrir Visual Studio Code utilizando el comando 'code'.
|
||||||
|
|
||||||
|
Este comando asume que VS Code ha sido instalado correctamente y que
|
||||||
|
el ejecutable 'code' está disponible en el PATH del sistema (lo cual
|
||||||
|
suele ser el caso si se habilita la opción al instalar VS Code).
|
||||||
|
"""
|
||||||
|
comando = 'code'
|
||||||
|
|
||||||
|
# Notificación en consola para el desarrollador
|
||||||
|
print(f"[*] Intentando ejecutar el comando: '{comando}'...")
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Ejecutamos el comando de forma asíncrona (Popen) para evitar que
|
||||||
|
# la interfaz de Tkinter se bloquee mientras se abre VS Code.
|
||||||
|
subprocess.Popen([comando])
|
||||||
|
print("[+] Visual Studio Code lanzado exitosamente.")
|
||||||
|
|
||||||
|
except FileNotFoundError:
|
||||||
|
# Esto ocurre si el comando 'code' no está en el PATH
|
||||||
|
mensaje_error = (
|
||||||
|
"===================================================\n"
|
||||||
|
f"ERROR: El comando '{comando}' no se encontró en el PATH del sistema.\n"
|
||||||
|
"Asegúrate de que Visual Studio Code esté instalado y de que el comando 'code' "
|
||||||
|
"esté configurado para ser accesible desde la terminal.\n"
|
||||||
|
"==================================================="
|
||||||
|
)
|
||||||
|
print(mensaje_error)
|
||||||
|
except Exception as e:
|
||||||
|
# Captura cualquier otro error (ej. permisos)
|
||||||
|
print(f"[-] Ocurrió un error inesperado al intentar abrir VS Code: {e}")
|
||||||
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
import platform
|
||||||
|
from contextlib import nullcontext
|
||||||
|
|
||||||
|
_OS = nullcontext
|
||||||
|
|
||||||
|
def getPlataforma():
|
||||||
|
if _OS== nullcontext:
|
||||||
|
|
||||||
|
|
||||||
|
def accion_placeholder(nombre_accion):
|
||||||
|
"""
|
||||||
|
Función placeholder temporal para acciones que aún no tienen implementación.
|
||||||
|
Simplemente imprime un mensaje en la consola.
|
||||||
|
"""
|
||||||
|
print(f"Acción pendiente de implementación: {nombre_accion}")
|
||||||
|
|
||||||
|
def _obtener_datos_sistema():
|
||||||
|
"""
|
||||||
|
Función placeholder para la tarea T1.3 (recursos del sistema).
|
||||||
|
Esta función se llenará con la lógica para obtener datos de CPU/RAM.
|
||||||
|
"""
|
||||||
|
print("Iniciando la recopilación de datos del sistema...")
|
||||||
|
# Lógica a añadir aquí en el futuro (usando psutil, por ejemplo)
|
||||||
|
tmpVar = platform.system().lower()
|
||||||
|
if tmpVar.__contains__("windows"):
|
||||||
|
print("Sistema operativo detectado: Windows")
|
||||||
|
return {"WINDOWS"}
|
||||||
|
elif tmpVar.__contains__("darwin"):
|
||||||
|
print("Sistema operativo detectado: MacOS")
|
||||||
|
return {"MACOS"}
|
||||||
|
else:
|
||||||
|
print("Sistema operativo detectado: Linux/Unix")
|
||||||
|
return {"LINUX"}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
out-null
|
||||||
|
cls
|
||||||
|
|
||||||
|
$saludo='Hola Usuario'
|
||||||
|
Write-Host $saludo
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
echo "Hello, World!"
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
|
# Importación de la lógica específica para abrir VS Code
|
||||||
|
from logica.T1.runVScode import abrir_vscode
|
||||||
|
# Importación de las acciones generales (placeholders y futuras funciones)
|
||||||
|
from logica.controlador import accion_placeholder, obtener_datos_sistema
|
||||||
|
|
||||||
|
|
||||||
class PanelLateral(ttk.Frame):
|
class PanelLateral(ttk.Frame):
|
||||||
|
|
@ -9,41 +13,70 @@ class PanelLateral(ttk.Frame):
|
||||||
super().__init__(parent, *args, **kwargs)
|
super().__init__(parent, *args, **kwargs)
|
||||||
self.pack(fill="y", padx=5, pady=5)
|
self.pack(fill="y", padx=5, pady=5)
|
||||||
|
|
||||||
|
self.configurar_estilos_locales(parent) # Asegura que los estilos funcionen
|
||||||
|
|
||||||
# Entrada superior (amarilla)
|
# Entrada superior (amarilla)
|
||||||
ttk.Entry(self, width=25, style='Yellow.TEntry').pack(fill="x", pady=10, padx=5)
|
ttk.Entry(self, width=25, style='Yellow.TEntry').pack(fill="x", pady=10, padx=5, ipady=3)
|
||||||
|
|
||||||
# 1. Área de Extracción/Navegación
|
# 1. Área de Extracción/Navegación
|
||||||
self.crear_seccion(
|
acciones_extraccion = [
|
||||||
parent_frame=self,
|
# T1.3 - Conectamos el botón de extracción a la función de obtención de datos del sistema
|
||||||
titulo="",
|
("Extraer datos", lambda: obtener_datos_sistema()),
|
||||||
botones=["Extraer datos", "Navegar", "Buscar API Google"]
|
("Navegar", lambda: accion_placeholder("Navegar")),
|
||||||
)
|
("Buscar API Google", lambda: accion_placeholder("Buscar API Google"))
|
||||||
|
]
|
||||||
|
self.crear_seccion(self, titulo="", acciones=acciones_extraccion)
|
||||||
|
|
||||||
# 2. Área de Aplicaciones
|
# 2. Área de Aplicaciones
|
||||||
self.crear_seccion(
|
acciones_aplicaciones = [
|
||||||
parent_frame=self,
|
# CONEXIÓN: Usa la función específica abrir_vscode
|
||||||
titulo="Aplicaciones",
|
("Visual Code", abrir_vscode),
|
||||||
botones=["Visual Code", "App2", "App3"]
|
("App2", lambda: accion_placeholder("App2")),
|
||||||
)
|
("App3", lambda: accion_placeholder("App3"))
|
||||||
|
]
|
||||||
|
self.crear_seccion(self, titulo="Aplicaciones", acciones=acciones_aplicaciones)
|
||||||
|
|
||||||
# 3. Área de Procesos Batch
|
# 3. Área de Procesos Batch
|
||||||
self.crear_seccion(
|
acciones_batch = [
|
||||||
parent_frame=self,
|
("Copias de seguridad", lambda: accion_placeholder("Copias de seguridad"))
|
||||||
titulo="Procesos batch",
|
]
|
||||||
botones=["Copias de seguridad"]
|
self.crear_seccion(self, titulo="Procesos batch", acciones=acciones_batch)
|
||||||
)
|
|
||||||
|
|
||||||
# Espaciador para empujar los elementos inferiores si los hubiera
|
# Espaciador para empujar los elementos inferiores si los hubiera
|
||||||
|
# CORRECCIÓN: Eliminamos el argumento 'bg' problemático y permitimos la herencia de color.
|
||||||
tk.Frame(self, height=1).pack(expand=True, fill="both")
|
tk.Frame(self, height=1).pack(expand=True, fill="both")
|
||||||
|
|
||||||
def crear_seccion(self, parent_frame, titulo, botones):
|
def configurar_estilos_locales(self, parent):
|
||||||
"""Función helper para crear secciones de etiquetas y botones."""
|
"""Configura estilos que deberían estar en la ventana principal, o crea placeholders."""
|
||||||
if titulo:
|
style = ttk.Style(parent)
|
||||||
ttk.Label(parent_frame, text=titulo).pack(fill="x", pady=(10, 0), padx=5)
|
# Estilo de la entrada amarilla
|
||||||
|
style.configure('Yellow.TEntry',
|
||||||
|
fieldbackground='#fff8e1',
|
||||||
|
foreground='#333333',
|
||||||
|
padding=[5, 5],
|
||||||
|
relief='solid',
|
||||||
|
borderwidth=1)
|
||||||
|
|
||||||
frame_botones = ttk.LabelFrame(parent_frame, text="")
|
# Estilo de los botones (Verde)
|
||||||
|
style.configure('Green.TButton',
|
||||||
|
background='#4CAF50',
|
||||||
|
foreground='white',
|
||||||
|
font=('Arial', 10, 'bold'),
|
||||||
|
relief='flat',
|
||||||
|
padding=[10, 5])
|
||||||
|
style.map('Green.TButton', background=[('active', '#388E3C'), ('pressed', '#1B5E20')])
|
||||||
|
|
||||||
|
def crear_seccion(self, parent_frame, titulo, acciones):
|
||||||
|
"""
|
||||||
|
Función helper para crear secciones de etiquetas y botones.
|
||||||
|
'acciones' es una lista de tuplas: (texto_boton, comando_a_ejecutar)
|
||||||
|
"""
|
||||||
|
if titulo:
|
||||||
|
ttk.Label(parent_frame, text=titulo, font=('Arial', 11, 'bold')).pack(fill="x", pady=(10, 0), padx=5)
|
||||||
|
|
||||||
|
frame_botones = ttk.Frame(parent_frame, style='TFrame') # Usando TFrame para el contenedor de botones
|
||||||
frame_botones.pack(fill="x", pady=5, padx=5)
|
frame_botones.pack(fill="x", pady=5, padx=5)
|
||||||
|
|
||||||
for texto_boton in botones:
|
for texto_boton, comando in acciones:
|
||||||
# Todos los botones usan el estilo 'Green.TButton' para simular el color
|
# Conexión del botón:
|
||||||
ttk.Button(frame_botones, text=texto_boton, style='Green.TButton').pack(fill="x", pady=5)
|
ttk.Button(frame_botones, text=texto_boton, command=comando, style='Green.TButton').pack(fill="x", pady=5)
|
||||||
Loading…
Reference in New Issue