feat: Enhance launcher history and logging with detailed execution records for scripts, including support for VS Code integration
This commit is contained in:
parent
24a0ece0b4
commit
f68bea6056
|
@ -0,0 +1,82 @@
|
|||
# GEMINI.md
|
||||
|
||||
## Project Overview
|
||||
|
||||
**ParamManagerScripts** is a comprehensive script management and execution system. It provides a web-based interface to organize, configure, and run various types of scripts (Python, C#, etc.) in a controlled and structured manner. The system is designed to work with specific working directories where scripts process files, making it ideal for data processing and automation tasks.
|
||||
|
||||
### Key Features
|
||||
|
||||
* **Hierarchical Configuration:** A three-level configuration system (Global, Group, and Work) allows for flexible and granular control over script parameters.
|
||||
* **Script Management by Categories:** The system supports different types of scripts, including traditional Python scripts, Python scripts with GUIs, C# projects, and specialized Python projects.
|
||||
* **Web-based Frontend:** The application is accessible via a web browser at `http://127.0.0.1:5000/` and includes a real-time log panel using WebSockets, working directory management for each script group, and integration with popular code editors (VS Code, Cursor, Visual Studio).
|
||||
* **System Tray Icon:** A system tray icon provides quick access to the application.
|
||||
* **Launcher System:** The application includes a launcher system for executing scripts, with specific launchers for different script types.
|
||||
* **Shared Services:** The project provides a set of shared services for common tasks, including an `ExcelService` for working with Excel files, a `LanguageService` for language detection, and an `LLMService` for integrating with large language models.
|
||||
|
||||
## Building and Running
|
||||
|
||||
### Dependencies
|
||||
|
||||
The project requires the following Python libraries:
|
||||
|
||||
* flask
|
||||
* flask_sock
|
||||
* pystray
|
||||
* Pillow
|
||||
* requests
|
||||
* psutil
|
||||
|
||||
Install them using pip:
|
||||
|
||||
```bash
|
||||
pip install flask flask_sock pystray Pillow requests psutil
|
||||
```
|
||||
|
||||
### Running the Application
|
||||
|
||||
To run the application, execute the following command in the project's root directory:
|
||||
|
||||
```bash
|
||||
python app.py
|
||||
```
|
||||
|
||||
The application will be accessible at `http://127.0.0.1:5000/`.
|
||||
|
||||
## Development Conventions
|
||||
|
||||
### Configuration Hierarchy
|
||||
|
||||
The system uses a cascading configuration model to manage script parameters. The configuration is merged from three levels, with each level overriding the previous one:
|
||||
|
||||
1. **Level 1 (Global):** `data/data.json` - Stores global variables available to all scripts.
|
||||
2. **Level 2 (Group):** `backend/script_groups/<GroupName>/script_config.json` - Defines parameters shared by all scripts within a group.
|
||||
3. **Level 3 (Work):** `<WorkingDirectory>/work_dir.json` - Contains the specific input data for a script's execution.
|
||||
|
||||
Before execution, the launcher reads these files, combines them, and generates a single `script_config.json` in the script's folder. The `load_configuration()` utility function in `backend.script_utils` is used to read this consolidated configuration.
|
||||
|
||||
### Script Documentation
|
||||
|
||||
The launcher uses JSON files to display information about script groups and individual scripts in the web interface.
|
||||
|
||||
* **`description.json`:** Located in the root of a script group's directory, this file contains the group's name, description, version, and author.
|
||||
* **`scripts_description.json`:** Also in the group's root, this file provides details for each script, including a display name, short and long descriptions, and a `hidden` flag to control visibility in the UI.
|
||||
|
||||
### Output Encoding
|
||||
|
||||
All standard output (`stdout`) from scripts is captured and displayed in the frontend's log panel. To ensure proper rendering, all script output **must** be UTF-8 encoded. The execution environment is automatically configured to use UTF-8, so in most cases, a simple `print()` is sufficient.
|
||||
|
||||
### Shared Services
|
||||
|
||||
The project includes a `services` directory with reusable components for common tasks.
|
||||
|
||||
#### ExcelService
|
||||
|
||||
The `ExcelService` (`services/excel/excel_service.py`) simplifies reading and writing Excel files, with features like retry-on-open and formatting options.
|
||||
|
||||
#### LanguageService
|
||||
|
||||
The `LanguageService` (`services/language/`) provides language detection capabilities.
|
||||
|
||||
#### LLMService
|
||||
|
||||
The `LLMService` (`services/llm/`) offers a factory for creating clients for various Large Language Models (OpenAI, Groq, Claude, etc.). API keys for these services should be stored in a `.env` file in the project's root directory.
|
|
@ -1,5 +1,70 @@
|
|||
{
|
||||
"history": [
|
||||
{
|
||||
"id": "4372845c",
|
||||
"group_id": "2",
|
||||
"script_name": "main.py",
|
||||
"executed_date": "2025-08-26T10:08:25.225254Z",
|
||||
"arguments": [],
|
||||
"working_directory": "D:/Proyectos/Scripts/RS485/MaselliSimulatorApp",
|
||||
"python_env": "tia_scripting",
|
||||
"executable_type": "pythonw.exe",
|
||||
"status": "running",
|
||||
"pid": 22164,
|
||||
"execution_time": null
|
||||
},
|
||||
{
|
||||
"id": "d9e341da",
|
||||
"group_id": "2",
|
||||
"script_name": "main.py",
|
||||
"executed_date": "2025-08-26T09:58:50.101462Z",
|
||||
"arguments": [],
|
||||
"working_directory": "D:/Proyectos/Scripts/RS485/MaselliSimulatorApp",
|
||||
"python_env": "tia_scripting",
|
||||
"executable_type": "pythonw.exe",
|
||||
"status": "running",
|
||||
"pid": 30848,
|
||||
"execution_time": null
|
||||
},
|
||||
{
|
||||
"id": "4450d452",
|
||||
"group_id": "2",
|
||||
"script_name": "main.py",
|
||||
"executed_date": "2025-08-25T15:15:47.917676Z",
|
||||
"arguments": [],
|
||||
"working_directory": "D:/Proyectos/Scripts/RS485/MaselliSimulatorApp",
|
||||
"python_env": "tia_scripting",
|
||||
"executable_type": "pythonw.exe",
|
||||
"status": "running",
|
||||
"pid": 12240,
|
||||
"execution_time": null
|
||||
},
|
||||
{
|
||||
"id": "7ba36e07",
|
||||
"group_id": "2",
|
||||
"script_name": "main.py",
|
||||
"executed_date": "2025-08-25T10:44:34.660713Z",
|
||||
"arguments": [],
|
||||
"working_directory": "D:/Proyectos/Scripts/RS485/MaselliSimulatorApp",
|
||||
"python_env": "tia_scripting",
|
||||
"executable_type": "pythonw.exe",
|
||||
"status": "running",
|
||||
"pid": 31496,
|
||||
"execution_time": null
|
||||
},
|
||||
{
|
||||
"id": "086ddda3",
|
||||
"group_id": "2",
|
||||
"script_name": "main.py",
|
||||
"executed_date": "2025-08-25T10:05:03.231810Z",
|
||||
"arguments": [],
|
||||
"working_directory": "D:/Proyectos/Scripts/RS485/MaselliSimulatorApp",
|
||||
"python_env": "tia_scripting",
|
||||
"executable_type": "pythonw.exe",
|
||||
"status": "running",
|
||||
"pid": 29848,
|
||||
"execution_time": null
|
||||
},
|
||||
{
|
||||
"id": "d8b839b6",
|
||||
"group_id": "2",
|
||||
|
|
55
data/log.txt
55
data/log.txt
|
@ -0,0 +1,55 @@
|
|||
[10:05:03] Ejecutando script GUI: main.py
|
||||
[10:05:03] Entorno Python: tia_scripting
|
||||
[10:05:03] Ejecutable: pythonw.exe (sin logging)
|
||||
[10:05:03] Comando: C:\Users\migue\miniconda3\envs\tia_scripting\pythonw.exe D:/Proyectos/Scripts/RS485/MaselliSimulatorApp\main.py
|
||||
[10:05:03] Directorio: D:/Proyectos/Scripts/RS485/MaselliSimulatorApp
|
||||
[10:05:03] Encoding: UTF-8 (PYTHONUTF8=1, PYTHONIOENCODING=utf-8)
|
||||
[10:05:03] ==================================================
|
||||
[10:05:03] Script GUI ejecutado sin logging (pythonw.exe)
|
||||
[10:05:03] PID: 29848
|
||||
[10:05:03] ==================================================
|
||||
[10:05:03] ID de ejecución: 086ddda3
|
||||
[10:44:34] Ejecutando script GUI: main.py
|
||||
[10:44:34] Entorno Python: tia_scripting
|
||||
[10:44:34] Ejecutable: pythonw.exe (sin logging)
|
||||
[10:44:34] Comando: C:\Users\migue\miniconda3\envs\tia_scripting\pythonw.exe D:/Proyectos/Scripts/RS485/MaselliSimulatorApp\main.py
|
||||
[10:44:34] Directorio: D:/Proyectos/Scripts/RS485/MaselliSimulatorApp
|
||||
[10:44:34] Encoding: UTF-8 (PYTHONUTF8=1, PYTHONIOENCODING=utf-8)
|
||||
[10:44:34] ==================================================
|
||||
[10:44:34] Script GUI ejecutado sin logging (pythonw.exe)
|
||||
[10:44:34] PID: 31496
|
||||
[10:44:34] ==================================================
|
||||
[10:44:34] ID de ejecución: 7ba36e07
|
||||
[15:15:47] Ejecutando script GUI: main.py
|
||||
[15:15:47] Entorno Python: tia_scripting
|
||||
[15:15:47] Ejecutable: pythonw.exe (sin logging)
|
||||
[15:15:47] Comando: C:\Users\migue\miniconda3\envs\tia_scripting\pythonw.exe D:/Proyectos/Scripts/RS485/MaselliSimulatorApp\main.py
|
||||
[15:15:47] Directorio: D:/Proyectos/Scripts/RS485/MaselliSimulatorApp
|
||||
[15:15:47] Encoding: UTF-8 (PYTHONUTF8=1, PYTHONIOENCODING=utf-8)
|
||||
[15:15:47] ==================================================
|
||||
[15:15:47] Script GUI ejecutado sin logging (pythonw.exe)
|
||||
[15:15:47] PID: 12240
|
||||
[15:15:47] ==================================================
|
||||
[15:15:47] ID de ejecución: 4450d452
|
||||
[09:58:50] Ejecutando script GUI: main.py
|
||||
[09:58:50] Entorno Python: tia_scripting
|
||||
[09:58:50] Ejecutable: pythonw.exe (sin logging)
|
||||
[09:58:50] Comando: C:\Users\migue\miniconda3\envs\tia_scripting\pythonw.exe D:/Proyectos/Scripts/RS485/MaselliSimulatorApp\main.py
|
||||
[09:58:50] Directorio: D:/Proyectos/Scripts/RS485/MaselliSimulatorApp
|
||||
[09:58:50] Encoding: UTF-8 (PYTHONUTF8=1, PYTHONIOENCODING=utf-8)
|
||||
[09:58:50] ==================================================
|
||||
[09:58:50] Script GUI ejecutado sin logging (pythonw.exe)
|
||||
[09:58:50] PID: 30848
|
||||
[09:58:50] ==================================================
|
||||
[09:58:50] ID de ejecución: d9e341da
|
||||
[10:08:25] Ejecutando script GUI: main.py
|
||||
[10:08:25] Entorno Python: tia_scripting
|
||||
[10:08:25] Ejecutable: pythonw.exe (sin logging)
|
||||
[10:08:25] Comando: C:\Users\migue\miniconda3\envs\tia_scripting\pythonw.exe D:/Proyectos/Scripts/RS485/MaselliSimulatorApp\main.py
|
||||
[10:08:25] Directorio: D:/Proyectos/Scripts/RS485/MaselliSimulatorApp
|
||||
[10:08:25] Encoding: UTF-8 (PYTHONUTF8=1, PYTHONIOENCODING=utf-8)
|
||||
[10:08:25] ==================================================
|
||||
[10:08:25] Script GUI ejecutado sin logging (pythonw.exe)
|
||||
[10:08:25] PID: 22164
|
||||
[10:08:25] ==================================================
|
||||
[10:08:25] ID de ejecución: 4372845c
|
|
@ -196,7 +196,7 @@ class CSharpLauncherManager {
|
|||
}
|
||||
|
||||
showCSharpProjectButtons() {
|
||||
const buttons = ['cursor-csharp-btn', 'vs2022-csharp-btn', 'folder-csharp-btn', 'copy-path-csharp-btn', 'manage-csharp-executables-btn'];
|
||||
const buttons = ['vscode-csharp-btn', 'cursor-csharp-btn', 'vs2022-csharp-btn', 'folder-csharp-btn', 'copy-path-csharp-btn', 'manage-csharp-executables-btn'];
|
||||
buttons.forEach(id => {
|
||||
const btn = document.getElementById(id);
|
||||
if (btn) btn.style.display = 'block';
|
||||
|
@ -204,7 +204,7 @@ class CSharpLauncherManager {
|
|||
}
|
||||
|
||||
hideCSharpProjectButtons() {
|
||||
const buttons = ['cursor-csharp-btn', 'vs2022-csharp-btn', 'folder-csharp-btn', 'copy-path-csharp-btn', 'manage-csharp-executables-btn'];
|
||||
const buttons = ['vscode-csharp-btn', 'cursor-csharp-btn', 'vs2022-csharp-btn', 'folder-csharp-btn', 'copy-path-csharp-btn', 'manage-csharp-executables-btn'];
|
||||
buttons.forEach(id => {
|
||||
const btn = document.getElementById(id);
|
||||
if (btn) btn.style.display = 'none';
|
||||
|
@ -864,7 +864,7 @@ async function openCSharpProjectInEditor(editor) {
|
|||
|
||||
const result = await response.json();
|
||||
if (response.ok && result.status === 'success') {
|
||||
const editorName = editor === 'cursor' ? 'Cursor' : 'Visual Studio 2022';
|
||||
const editorName = editor === 'cursor' ? 'Cursor' : editor === 'vscode' ? 'VS Code' : 'Visual Studio 2022';
|
||||
let message = `${editorName} abierto exitosamente`;
|
||||
|
||||
// Agregar información específica para VS2022
|
||||
|
|
|
@ -426,6 +426,12 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button onclick="openCSharpProjectInEditor('vscode')"
|
||||
class="bg-white text-gray-700 px-4 py-3 rounded-lg border-2 border-gray-300 shadow-sm hover:shadow-md transition-shadow"
|
||||
id="vscode-csharp-btn" style="display: none;" title="Abrir proyecto en VS Code">
|
||||
<img src="{{ url_for('static', filename='icons/vscode.png') }}" class="w-7 h-7"
|
||||
alt="VS Code Icon">
|
||||
</button>
|
||||
<button onclick="openCSharpProjectInEditor('cursor')"
|
||||
class="bg-white text-gray-700 px-4 py-3 rounded-lg border-2 border-gray-300 shadow-sm hover:shadow-md transition-shadow"
|
||||
id="cursor-csharp-btn" style="display: none;" title="Abrir proyecto en Cursor">
|
||||
|
|
Loading…
Reference in New Issue