From 2e7c80bae895df61729cccc033be8ac80cba45e4 Mon Sep 17 00:00:00 2001 From: Egutierrez Date: Mon, 8 Sep 2025 02:52:33 +0200 Subject: [PATCH] Refactor and enhance Marimo session files with new functionality and improved structure --- .../session/consola_para_marimo.py.json | 60 ++++++++++++++ .../session/mejora_shell_mowidget.py.json | 82 ++++++++++++++++--- .../session/python_cargar_librerias.py.json | 60 ++++++++++++++ __marimo__/session/shell_carga_local.py.json | 60 ++++++++++++++ ..._mowidget.py => python_cargar_librerias.py | 60 ++------------ shell_carga_local.py | 38 +++++++++ 6 files changed, 297 insertions(+), 63 deletions(-) create mode 100644 __marimo__/session/consola_para_marimo.py.json create mode 100644 __marimo__/session/python_cargar_librerias.py.json create mode 100644 __marimo__/session/shell_carga_local.py.json rename mejora_shell_mowidget.py => python_cargar_librerias.py (77%) create mode 100644 shell_carga_local.py diff --git a/__marimo__/session/consola_para_marimo.py.json b/__marimo__/session/consola_para_marimo.py.json new file mode 100644 index 0000000..d247595 --- /dev/null +++ b/__marimo__/session/consola_para_marimo.py.json @@ -0,0 +1,60 @@ +{ + "version": "1", + "metadata": { + "marimo_version": "0.15.2" + }, + "cells": [ + { + "id": "Hbol", + "code_hash": "1d0db38904205bec4d6f6f6a1f6cec3e", + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], + "console": [] + }, + { + "id": "jNiy", + "code_hash": "ed0e59fac5eadee837eb138b47d09a4e", + "outputs": [ + { + "type": "data", + "data": { + "text/html": "

Python: Cargar librerias desde rutas locales para ediciones

" + } + } + ], + "console": [] + }, + { + "id": "MJUe", + "code_hash": "161ebcb820075ae0ed102ae0a00f47c2", + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], + "console": [] + }, + { + "id": "vblA", + "code_hash": "50bee6be6f844ae38ba836c4d509cda2", + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], + "console": [] + } + ] +} \ No newline at end of file diff --git a/__marimo__/session/mejora_shell_mowidget.py.json b/__marimo__/session/mejora_shell_mowidget.py.json index 8360c48..71d9ab3 100644 --- a/__marimo__/session/mejora_shell_mowidget.py.json +++ b/__marimo__/session/mejora_shell_mowidget.py.json @@ -7,49 +7,111 @@ { "id": "Hbol", "code_hash": "1d0db38904205bec4d6f6f6a1f6cec3e", - "outputs": [], + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], "console": [] }, { "id": "MJUe", "code_hash": "161ebcb820075ae0ed102ae0a00f47c2", - "outputs": [], + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], "console": [] }, { "id": "vblA", "code_hash": "f7f5821d3695ae3da07f153aa5a1a7a6", - "outputs": [], + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], "console": [] }, { "id": "bkHC", "code_hash": "dad9563ab733290d13df7d9f3c1f904b", - "outputs": [], + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], "console": [] }, { "id": "lEQa", "code_hash": "eea45b0636482cfa9d88aa3c65db2599", - "outputs": [], - "console": [] + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], + "console": [ + { + "type": "stream", + "name": "stdout", + "text": "Script guardado en scripts/mi_script.sh y listo para ejecutarse.\n" + } + ] }, { "id": "PKri", - "code_hash": "de1dd307acb19774134d7d0913854010", - "outputs": [], + "code_hash": "4cc7a1b87ff12543d3fffe238e2a2d60", + "outputs": [ + { + "type": "data", + "data": { + "text/html": "" + } + } + ], "console": [] }, { "id": "Xref", "code_hash": "9a13086a1230097669e15deae4b7eb72", - "outputs": [], + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], "console": [] }, { "id": "SFPL", "code_hash": null, - "outputs": [], + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], "console": [] } ] diff --git a/__marimo__/session/python_cargar_librerias.py.json b/__marimo__/session/python_cargar_librerias.py.json new file mode 100644 index 0000000..d247595 --- /dev/null +++ b/__marimo__/session/python_cargar_librerias.py.json @@ -0,0 +1,60 @@ +{ + "version": "1", + "metadata": { + "marimo_version": "0.15.2" + }, + "cells": [ + { + "id": "Hbol", + "code_hash": "1d0db38904205bec4d6f6f6a1f6cec3e", + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], + "console": [] + }, + { + "id": "jNiy", + "code_hash": "ed0e59fac5eadee837eb138b47d09a4e", + "outputs": [ + { + "type": "data", + "data": { + "text/html": "

Python: Cargar librerias desde rutas locales para ediciones

" + } + } + ], + "console": [] + }, + { + "id": "MJUe", + "code_hash": "161ebcb820075ae0ed102ae0a00f47c2", + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], + "console": [] + }, + { + "id": "vblA", + "code_hash": "50bee6be6f844ae38ba836c4d509cda2", + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], + "console": [] + } + ] +} \ No newline at end of file diff --git a/__marimo__/session/shell_carga_local.py.json b/__marimo__/session/shell_carga_local.py.json new file mode 100644 index 0000000..732671e --- /dev/null +++ b/__marimo__/session/shell_carga_local.py.json @@ -0,0 +1,60 @@ +{ + "version": "1", + "metadata": { + "marimo_version": "0.15.2" + }, + "cells": [ + { + "id": "Hbol", + "code_hash": "1d0db38904205bec4d6f6f6a1f6cec3e", + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], + "console": [] + }, + { + "id": "CKaf", + "code_hash": "51c9f6fae7a49cf2ab61edf5a1909ddc", + "outputs": [ + { + "type": "data", + "data": { + "text/html": "

Shell: Ejecucion de comandos de terminal

" + } + } + ], + "console": [] + }, + { + "id": "vblA", + "code_hash": "6223d6d79d5e4a56fa0fb9a4d7d96559", + "outputs": [ + { + "type": "data", + "data": { + "text/plain": "" + } + } + ], + "console": [] + }, + { + "id": "PKri", + "code_hash": "4cc7a1b87ff12543d3fffe238e2a2d60", + "outputs": [ + { + "type": "data", + "data": { + "text/html": "" + } + } + ], + "console": [] + } + ] +} \ No newline at end of file diff --git a/mejora_shell_mowidget.py b/python_cargar_librerias.py similarity index 77% rename from mejora_shell_mowidget.py rename to python_cargar_librerias.py index 16ee4bb..de5cdd5 100644 --- a/mejora_shell_mowidget.py +++ b/python_cargar_librerias.py @@ -7,6 +7,12 @@ app = marimo.App(width="medium") @app.cell def _(): import marimo as mo + return (mo,) + + +@app.cell +def _(mo): + mo.md(r"""# Python: Cargar librerias desde rutas locales para ediciones""") return @@ -83,6 +89,7 @@ def _(): @app.cell def _(import_local_libs): LIBS = { + # "nombre de la libreria" : "ruta de la libreria" "moutils": "/home/lucas/DataProyects/git_proyects/moutils" } @@ -90,59 +97,6 @@ def _(import_local_libs): # Ahora ya puedes importar normal from moutils import shell, ShellWidget - return (ShellWidget,) - - -@app.cell -def _(): - bash_code = """#!/bin/bash - - # Espera input del usuario - read -p "Write the host to ping" destino - - # Ejecuta ping indefinidamente - ping "$destino" - - """ - return (bash_code,) - - -@app.cell -def _(bash_code): - import os - - # Crear la carpeta scripts si no existe - os.makedirs("scripts", exist_ok=True) - - # Ruta del archivo .sh dentro de scripts - script_path = os.path.join("scripts", "mi_script.sh") - - # Guardar el contenido en el archivo - with open(script_path, "w") as f: - f.write(bash_code) - - # Dar permisos de ejecución - os.chmod(script_path, 0o755) - - print(f"Script guardado en {script_path} y listo para ejecutarse.") - return - - -@app.cell -def _(ShellWidget): - console = ShellWidget(command="bash -x ./scripts/mi_script.sh", run=True) - console - return - - -@app.cell -def _(): - # console.kill() - return - - -@app.cell -def _(): return diff --git a/shell_carga_local.py b/shell_carga_local.py new file mode 100644 index 0000000..01fecf0 --- /dev/null +++ b/shell_carga_local.py @@ -0,0 +1,38 @@ +import marimo + +__generated_with = "0.15.2" +app = marimo.App(width="medium") + + +@app.cell +def _(): + import marimo as mo + return (mo,) + + +@app.cell +def _(mo): + mo.md(r"""# Shell: Ejecucion de comandos de terminal""") + return + + +@app.cell +def _(): + import sys + import os + sys.path.append(os.path.join(os.environ["SNIPPETS_ROUTE"], "widgets")) + + # Ahora ya puedes importar normal + from marimo_shell import shell, ShellWidget + return (ShellWidget,) + + +@app.cell +def _(ShellWidget): + console = ShellWidget(command="cd /; ls -la", run=True) + console + return + + +if __name__ == "__main__": + app.run()