zerochat 7.10.0__tar.gz → 7.11.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {zerochat-7.10.0/zerochat.egg-info → zerochat-7.11.0}/PKG-INFO +1 -1
- {zerochat-7.10.0 → zerochat-7.11.0}/pyproject.toml +1 -1
- {zerochat-7.10.0 → zerochat-7.11.0/zerochat.egg-info}/PKG-INFO +1 -1
- {zerochat-7.10.0 → zerochat-7.11.0}/zerochat.py +32 -20
- {zerochat-7.10.0 → zerochat-7.11.0}/LICENSE +0 -0
- {zerochat-7.10.0 → zerochat-7.11.0}/README.md +0 -0
- {zerochat-7.10.0 → zerochat-7.11.0}/setup.cfg +0 -0
- {zerochat-7.10.0 → zerochat-7.11.0}/zerochat.egg-info/SOURCES.txt +0 -0
- {zerochat-7.10.0 → zerochat-7.11.0}/zerochat.egg-info/dependency_links.txt +0 -0
- {zerochat-7.10.0 → zerochat-7.11.0}/zerochat.egg-info/entry_points.txt +0 -0
- {zerochat-7.10.0 → zerochat-7.11.0}/zerochat.egg-info/top_level.txt +0 -0
|
@@ -40,7 +40,7 @@ import webbrowser
|
|
|
40
40
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
41
41
|
from pathlib import Path
|
|
42
42
|
|
|
43
|
-
SOURCE_BACKEND_VERSION = "7.
|
|
43
|
+
SOURCE_BACKEND_VERSION = "7.11.0"
|
|
44
44
|
|
|
45
45
|
def _read_source_version(filename: str) -> str | None:
|
|
46
46
|
"""Lee la versión de un archivo del repositorio cuando se ejecuta desde fuentes."""
|
|
@@ -108,9 +108,10 @@ def format_uptime(seconds: float) -> str:
|
|
|
108
108
|
|
|
109
109
|
class ConsoleControl:
|
|
110
110
|
"""Atajos de consola y línea de estado, solo para terminales interactivos."""
|
|
111
|
-
def __init__(self, server: ThreadingHTTPServer, parser: argparse.ArgumentParser):
|
|
111
|
+
def __init__(self, server: ThreadingHTTPServer, parser: argparse.ArgumentParser, target_url: str | None = None):
|
|
112
112
|
self.server = server
|
|
113
113
|
self.parser = parser
|
|
114
|
+
self.target_url = target_url
|
|
114
115
|
self.started_at = time.monotonic()
|
|
115
116
|
self.last_activity = self.started_at
|
|
116
117
|
self.stop_event = threading.Event()
|
|
@@ -190,7 +191,7 @@ class ConsoleControl:
|
|
|
190
191
|
if self.status_visible:
|
|
191
192
|
sys.stdout.write("\r\033[2K")
|
|
192
193
|
self.status_visible = False
|
|
193
|
-
print("\nComandos de consola: [h] ayuda · [x] salir ordenadamente\n", flush=True)
|
|
194
|
+
print("\nComandos de consola: [h] ayuda · [n] Navegador · [x] salir ordenadamente\n", flush=True)
|
|
194
195
|
print(self.parser.format_help().rstrip(), flush=True)
|
|
195
196
|
self.last_activity = time.monotonic()
|
|
196
197
|
|
|
@@ -201,7 +202,7 @@ class ConsoleControl:
|
|
|
201
202
|
with self.lock:
|
|
202
203
|
if time.monotonic() - self.last_activity < CONSOLE_STATUS_IDLE_SECONDS:
|
|
203
204
|
return
|
|
204
|
-
sys.stdout.write(f"\r\033[2KZeroChat activo {uptime} · [h] ayuda · [x] salir")
|
|
205
|
+
sys.stdout.write(f"\r\033[2KZeroChat activo {uptime} · [h] ayuda · [n] Navegador · [x] salir")
|
|
205
206
|
sys.stdout.flush()
|
|
206
207
|
self.status_visible = True
|
|
207
208
|
|
|
@@ -212,6 +213,9 @@ class ConsoleControl:
|
|
|
212
213
|
def _handle_key(self, key: str):
|
|
213
214
|
if key.lower() == "h":
|
|
214
215
|
self.show_help()
|
|
216
|
+
elif key.lower() == "n":
|
|
217
|
+
if self.target_url:
|
|
218
|
+
launch_browser(self.target_url)
|
|
215
219
|
elif key.lower() == "x":
|
|
216
220
|
self.log(f"[{time.strftime('%H:%M:%S')}] Deteniendo servidor ZeroChat...")
|
|
217
221
|
stop_zerochat_server(self.server)
|
|
@@ -2720,6 +2724,28 @@ def open_browser(url: str) -> bool:
|
|
|
2720
2724
|
)
|
|
2721
2725
|
|
|
2722
2726
|
|
|
2727
|
+
def launch_browser(url: str) -> bool:
|
|
2728
|
+
"""Abre el navegador en la URL de la sesión y muestra información o diagnóstico en consola."""
|
|
2729
|
+
termux_detected = is_termux_environment()
|
|
2730
|
+
if termux_detected:
|
|
2731
|
+
console_log(f"[{time.strftime('%H:%M:%S')}] Termux detectado; se abrirá mediante termux-open-url.", flush=True)
|
|
2732
|
+
console_log(f"[{time.strftime('%H:%M:%S')}] Abriendo navegador en la interfaz configurada...", flush=True)
|
|
2733
|
+
try:
|
|
2734
|
+
if not open_browser(url):
|
|
2735
|
+
raise RuntimeError("El lanzador de navegador devolvió un resultado sin éxito.")
|
|
2736
|
+
return True
|
|
2737
|
+
except Exception as e:
|
|
2738
|
+
console_log(f"[{time.strftime('%H:%M:%S')}] No se pudo abrir el navegador automáticamente: {e}", flush=True)
|
|
2739
|
+
console_log(" Traza de diagnóstico:", flush=True)
|
|
2740
|
+
traceback.print_exc()
|
|
2741
|
+
manual_command = get_manual_browser_command(url)
|
|
2742
|
+
if manual_command:
|
|
2743
|
+
console_log(" Termux detectado. Prueba este comando exacto:", flush=True)
|
|
2744
|
+
console_log(f" {manual_command}", flush=True)
|
|
2745
|
+
return False
|
|
2746
|
+
|
|
2747
|
+
|
|
2748
|
+
|
|
2723
2749
|
# ==============================================================================
|
|
2724
2750
|
# Punto de Entrada Principal (CLI)
|
|
2725
2751
|
# ==============================================================================
|
|
@@ -2800,25 +2826,11 @@ def main():
|
|
|
2800
2826
|
print(f" Auto-cierre : Desactivado")
|
|
2801
2827
|
print("=" * 64, flush=True)
|
|
2802
2828
|
|
|
2803
|
-
CONSOLE_CONTROL = ConsoleControl(server, parser)
|
|
2829
|
+
CONSOLE_CONTROL = ConsoleControl(server, parser, target_url=target_url)
|
|
2804
2830
|
CONSOLE_CONTROL.start()
|
|
2805
2831
|
|
|
2806
2832
|
if not args.no_browser:
|
|
2807
|
-
|
|
2808
|
-
if termux_detected:
|
|
2809
|
-
console_log(f"[{time.strftime('%H:%M:%S')}] Termux detectado; se abrirá mediante termux-open-url.", flush=True)
|
|
2810
|
-
console_log(f"[{time.strftime('%H:%M:%S')}] Abriendo navegador en la interfaz configurada...", flush=True)
|
|
2811
|
-
try:
|
|
2812
|
-
if not open_browser(target_url):
|
|
2813
|
-
raise RuntimeError("El lanzador de navegador devolvió un resultado sin éxito.")
|
|
2814
|
-
except Exception as e:
|
|
2815
|
-
console_log(f"[{time.strftime('%H:%M:%S')}] No se pudo abrir el navegador automáticamente: {e}", flush=True)
|
|
2816
|
-
console_log(" Traza de diagnóstico:", flush=True)
|
|
2817
|
-
traceback.print_exc()
|
|
2818
|
-
manual_command = get_manual_browser_command(target_url)
|
|
2819
|
-
if manual_command:
|
|
2820
|
-
console_log(" Termux detectado. Prueba este comando exacto:", flush=True)
|
|
2821
|
-
console_log(f" {manual_command}", flush=True)
|
|
2833
|
+
launch_browser(target_url)
|
|
2822
2834
|
|
|
2823
2835
|
if exit_on_close:
|
|
2824
2836
|
require_initial = not args.no_browser
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|