krnell 0.0.0-stage → 3.0.2
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.
- package/Iniciar_Linux.sh +129 -0
- package/Instalar_Atalho_Windows.cmd +40 -0
- package/Instalar_Ubuntu.sh +95 -0
- package/Painel.cmd +138 -0
- package/README.md +82 -2
- package/atualizador.py +148 -0
- package/bin/krnell.mjs +159 -0
- package/bridge.py +5280 -0
- package/config.example.json +57 -0
- package/contexto.py +204 -0
- package/dashboard_web.py +308 -0
- package/dns_duck.py +227 -0
- package/ferramentas/Liberar_Firewall.ps1 +96 -0
- package/ferramentas/firewall_linux.sh +67 -0
- package/ferramentas/install_windows.py +482 -0
- package/ferramentas/selecionar_provedor.py +76 -0
- package/iniciar.sh +255 -0
- package/keys.example.env +3 -0
- package/kimi.py +567 -0
- package/opencode_sync.py +265 -0
- package/package.json +68 -4
- package/painel.py +5612 -0
- package/painel_web.py +367 -0
- package/plugins/system-prompt/index.ts +409 -0
- package/provedores/kimi/bridge.mjs +4349 -0
- package/provedores/kimi/package.json +10 -0
- package/provedores_catalogo.py +27 -0
- package/tls_proxy.py +205 -0
- package/tui_core.py +604 -0
- package/web/dist/.vite/manifest.json +84 -0
- package/web/dist/assets/LogsPage-DkXN-I7o.js +2 -0
- package/web/dist/assets/LogsPage-OsSvuqxQ.js +2 -0
- package/web/dist/assets/TerminalPage-CZTPxVyx.js +1 -0
- package/web/dist/assets/TerminalPage-D208X99P.js +1 -0
- package/web/dist/assets/TerminalPage-DYGPu4ux.css +1 -0
- package/web/dist/assets/index-B5rIwous.js +1 -0
- package/web/dist/assets/index-CJE_a_Tn.js +27 -0
- package/web/dist/assets/index-COlDAcsY.js +1 -0
- package/web/dist/assets/index-Dzc8Obwp.css +1 -0
- package/web/dist/assets/index-LZadV7rx.js +27 -0
- package/web/dist/assets/index-o8xT03ZV.css +1 -0
- package/web/dist/assets/press-start-2p-2BZhbCiP.ttf +0 -0
- package/web/dist/assets/react-vendor-C475ILlI.js +49 -0
- package/web/dist/assets/terminal-vendor-DOrYoP_4.css +32 -0
- package/web/dist/assets/terminal-vendor-Dp03d74L.js +38 -0
- package/web/dist/assets/terminal-webgl-BRBWwLY7.js +75 -0
- package/web/dist/favicon.svg +1 -0
- package/web/dist/fonts/OFL.txt +93 -0
- package/web/dist/fonts/press-start-2p.ttf +0 -0
- package/web/dist/index.html +18 -0
- package/workbuddy.py +1965 -0
package/painel_web.py
ADDED
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""Adaptador REPL/Rich do Painel para a PTY do dashboard (Linux e Windows).
|
|
4
|
+
|
|
5
|
+
O transporte/xterm e o visual Mario pertencem ao frontend. Este arquivo não é
|
|
6
|
+
um servidor: importa o Painel, conserva comandos/render/wizard e adapta somente
|
|
7
|
+
o ciclo de vida dos processos e as operações específicas do sistema operacional.
|
|
8
|
+
Conectar, sair ou perder a PTY não inicia nem encerra o bridge.
|
|
9
|
+
|
|
10
|
+
.venv/bin/python -B painel_web.py --repl
|
|
11
|
+
.venv/bin/python -B painel_web.py --once
|
|
12
|
+
|
|
13
|
+
Ubuntu: chmod +x Instalar_Ubuntu.sh Iniciar_Linux.sh ferramentas/firewall_linux.sh
|
|
14
|
+
Instale com ./Instalar_Ubuntu.sh; ./Iniciar_Linux.sh --web-only usa o laboratório.
|
|
15
|
+
"""
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import argparse
|
|
19
|
+
from contextlib import contextmanager
|
|
20
|
+
from contextvars import ContextVar
|
|
21
|
+
import getpass
|
|
22
|
+
import os
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
import shutil
|
|
25
|
+
import signal
|
|
26
|
+
import subprocess
|
|
27
|
+
import sys
|
|
28
|
+
import time
|
|
29
|
+
from urllib.parse import urlsplit
|
|
30
|
+
|
|
31
|
+
import painel
|
|
32
|
+
from painel import Painel
|
|
33
|
+
from rich.console import Console
|
|
34
|
+
from rich.text import Text
|
|
35
|
+
|
|
36
|
+
ROOT = Path(__file__).resolve().parent
|
|
37
|
+
BRIDGE_LOG = ROOT / 'logs' / 'painel-bridge.log'
|
|
38
|
+
IS_WINDOWS = os.name == 'nt'
|
|
39
|
+
_CONTROLE_BRIDGE = ContextVar('controle_bridge_web', default=None)
|
|
40
|
+
DESCONEXAO = ('Painel desconectado — nenhum bridge foi encerrado; um bridge já '
|
|
41
|
+
'iniciado segue independente. Use /parar explicitamente para encerrá-lo.')
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class _ReinicioExplicitoNecessario(ValueError):
|
|
45
|
+
"""O core salvou uma configuração e tentou reiniciar implicitamente."""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _porta_bridge(cfg: dict) -> int:
|
|
49
|
+
valor = cfg.get('port', 8765)
|
|
50
|
+
if isinstance(valor, str) and valor.isascii() and valor.isdecimal():
|
|
51
|
+
valor = int(valor)
|
|
52
|
+
if type(valor) is not int or not 1 <= valor <= 65535:
|
|
53
|
+
raise ValueError('porta do bridge inválida no config.json (1 a 65535)')
|
|
54
|
+
return valor
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _validar_pid(pid) -> int:
|
|
58
|
+
# bool é subclasse de int; strings, PID 1, grupos e o próprio painel não valem.
|
|
59
|
+
if type(pid) is not int or pid <= 1 or pid == os.getpid():
|
|
60
|
+
raise ValueError('PID do bridge inválido; nenhum processo foi sinalizado')
|
|
61
|
+
return pid
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@contextmanager
|
|
65
|
+
def _sinais_de_desconexao():
|
|
66
|
+
anteriores = {}
|
|
67
|
+
|
|
68
|
+
def desconectar(_numero, _frame):
|
|
69
|
+
raise SystemExit(0)
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
for nome in ('SIGTERM', 'SIGHUP'):
|
|
73
|
+
numero = getattr(signal, nome, None)
|
|
74
|
+
if numero is not None:
|
|
75
|
+
anteriores[numero] = signal.signal(numero, desconectar)
|
|
76
|
+
yield
|
|
77
|
+
finally:
|
|
78
|
+
for numero, anterior in anteriores.items():
|
|
79
|
+
signal.signal(numero, anterior)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class PainelWeb(Painel):
|
|
83
|
+
"""Todos os comandos /, render Rich e ao_enter são os do Painel original."""
|
|
84
|
+
|
|
85
|
+
def ao_enter(self):
|
|
86
|
+
# Uma confirmação de wizard também é uma ação explícita. Mantém o
|
|
87
|
+
# comportamento de /model e /provedor sem autorizar tarefas de abertura.
|
|
88
|
+
token = _CONTROLE_BRIDGE.set('entrada_explicita')
|
|
89
|
+
try:
|
|
90
|
+
return super().ao_enter()
|
|
91
|
+
finally:
|
|
92
|
+
_CONTROLE_BRIDGE.reset(token)
|
|
93
|
+
|
|
94
|
+
def executar(self, linha):
|
|
95
|
+
token = _CONTROLE_BRIDGE.set('entrada_explicita')
|
|
96
|
+
try:
|
|
97
|
+
return super().executar(linha)
|
|
98
|
+
finally:
|
|
99
|
+
_CONTROLE_BRIDGE.reset(token)
|
|
100
|
+
|
|
101
|
+
def iniciar_bridge_na_abertura(self):
|
|
102
|
+
return None
|
|
103
|
+
|
|
104
|
+
def iniciar_checagem_firewall(self):
|
|
105
|
+
return None
|
|
106
|
+
|
|
107
|
+
def iniciar_dashboard_na_abertura(self):
|
|
108
|
+
return None
|
|
109
|
+
|
|
110
|
+
@staticmethod
|
|
111
|
+
def _abrir_dashboard(url: str):
|
|
112
|
+
# /web conserva o diagnóstico do core, mas não abre browser no servidor.
|
|
113
|
+
return ('ok', f'dashboard local — abra manualmente: {url}')
|
|
114
|
+
|
|
115
|
+
def _encerrar_com_o_painel(self) -> bool:
|
|
116
|
+
# Não fechar JobObject, não enviar sinal e não esperar/matar self.proc.
|
|
117
|
+
return False
|
|
118
|
+
|
|
119
|
+
def acao_parar(self, arg: str = ''):
|
|
120
|
+
token = _CONTROLE_BRIDGE.set('/parar')
|
|
121
|
+
try:
|
|
122
|
+
return super().acao_parar(arg)
|
|
123
|
+
finally:
|
|
124
|
+
_CONTROLE_BRIDGE.reset(token)
|
|
125
|
+
|
|
126
|
+
def acao_reiniciar(self, arg: str = ''):
|
|
127
|
+
token = _CONTROLE_BRIDGE.set('/reiniciar')
|
|
128
|
+
try:
|
|
129
|
+
return super().acao_reiniciar(arg)
|
|
130
|
+
finally:
|
|
131
|
+
_CONTROLE_BRIDGE.reset(token)
|
|
132
|
+
|
|
133
|
+
def rodar_tarefa(self, funcao, aviso):
|
|
134
|
+
# A permissão acompanha somente esta tarefa, inclusive se o core usar thread.
|
|
135
|
+
controle = _CONTROLE_BRIDGE.get()
|
|
136
|
+
|
|
137
|
+
def executar():
|
|
138
|
+
token = _CONTROLE_BRIDGE.set(controle)
|
|
139
|
+
try:
|
|
140
|
+
return funcao()
|
|
141
|
+
except _ReinicioExplicitoNecessario as exc:
|
|
142
|
+
return ('aviso', str(exc))
|
|
143
|
+
finally:
|
|
144
|
+
_CONTROLE_BRIDGE.reset(token)
|
|
145
|
+
|
|
146
|
+
return super().rodar_tarefa(executar, aviso)
|
|
147
|
+
|
|
148
|
+
def _status_atual(self) -> dict:
|
|
149
|
+
# Uma coleta nova evita usar o PID de um retrato antigo ao parar/reiniciar.
|
|
150
|
+
snap = self.coletor._coletar()
|
|
151
|
+
status = snap.get('status')
|
|
152
|
+
if not isinstance(status, dict) or status.get('status') != 'ok':
|
|
153
|
+
return {}
|
|
154
|
+
base = snap.get('base')
|
|
155
|
+
if base and urlsplit(base).hostname not in ('127.0.0.1', 'localhost', '::1'):
|
|
156
|
+
raise ValueError('controle de processo exige status local em loopback')
|
|
157
|
+
return status
|
|
158
|
+
|
|
159
|
+
def _iniciar_bridge(self):
|
|
160
|
+
"""Mesmo bridge/config do core; apenas spawn/readiness são diferentes."""
|
|
161
|
+
if self.proc and self.proc.poll() is None:
|
|
162
|
+
raise ValueError('o processo já está rodando')
|
|
163
|
+
if self.bridge_online() or self._status_atual():
|
|
164
|
+
raise ValueError('o bridge já está no ar')
|
|
165
|
+
BRIDGE_LOG.parent.mkdir(parents=True, exist_ok=True)
|
|
166
|
+
ambiente = {k: v for k, v in os.environ.items()
|
|
167
|
+
if k.upper() not in ('SUPER_BRIDGE_TERMINAL_TOKEN',
|
|
168
|
+
'SUPER_BRIDGE_ALLOWED_ORIGINS')}
|
|
169
|
+
opcoes = {'stdin': subprocess.DEVNULL, 'stderr': subprocess.STDOUT,
|
|
170
|
+
'cwd': str(ROOT), 'close_fds': True, 'env': ambiente}
|
|
171
|
+
if IS_WINDOWS:
|
|
172
|
+
# BREAKAWAY é intencional: sem ele um job do dono da PTY pode matar
|
|
173
|
+
# descendentes. Se o job proibir breakaway, falhamos sem fallback preso.
|
|
174
|
+
opcoes['creationflags'] = (getattr(subprocess, 'DETACHED_PROCESS', 0x00000008)
|
|
175
|
+
| getattr(subprocess, 'CREATE_NEW_PROCESS_GROUP', 0x00000200)
|
|
176
|
+
| getattr(subprocess, 'CREATE_BREAKAWAY_FROM_JOB', 0x01000000))
|
|
177
|
+
else:
|
|
178
|
+
opcoes['start_new_session'] = True
|
|
179
|
+
with BRIDGE_LOG.open('ab') as log:
|
|
180
|
+
self.proc = subprocess.Popen(
|
|
181
|
+
[sys.executable, '-B', str(ROOT / 'bridge.py'), '--config', 'config.json'],
|
|
182
|
+
stdout=log, **opcoes)
|
|
183
|
+
limite = time.monotonic() + 10.0
|
|
184
|
+
while time.monotonic() < limite:
|
|
185
|
+
if self.proc.poll() is not None:
|
|
186
|
+
raise ValueError('o bridge encerrou na partida — veja logs/painel-bridge.log')
|
|
187
|
+
status = self._status_atual()
|
|
188
|
+
if status.get('pid') == self.proc.pid:
|
|
189
|
+
return
|
|
190
|
+
time.sleep(0.2)
|
|
191
|
+
raise ValueError('o bridge não respondeu em 10s; o processo não foi encerrado — '
|
|
192
|
+
'veja logs/painel-bridge.log ou use /parar')
|
|
193
|
+
|
|
194
|
+
def _parar_bridge(self):
|
|
195
|
+
if _CONTROLE_BRIDGE.get() not in ('/parar', '/reiniciar', 'entrada_explicita'):
|
|
196
|
+
raise _ReinicioExplicitoNecessario(
|
|
197
|
+
'configuração salva; use /reiniciar para aplicá-la — '
|
|
198
|
+
'nenhum processo foi encerrado automaticamente')
|
|
199
|
+
proprio = self.proc if self.proc and self.proc.poll() is None else None
|
|
200
|
+
if proprio is not None:
|
|
201
|
+
pid = _validar_pid(proprio.pid)
|
|
202
|
+
else:
|
|
203
|
+
status = self._status_atual()
|
|
204
|
+
if not status:
|
|
205
|
+
return
|
|
206
|
+
pid = _validar_pid(status.get('pid'))
|
|
207
|
+
try:
|
|
208
|
+
# No POSIX, somente SIGTERM e somente após comando expresso.
|
|
209
|
+
# No Windows, os.kill(SIGTERM) usa TerminateProcess, sem taskkill.
|
|
210
|
+
os.kill(pid, signal.SIGTERM)
|
|
211
|
+
except ProcessLookupError:
|
|
212
|
+
if proprio is not None:
|
|
213
|
+
self.proc = None
|
|
214
|
+
return
|
|
215
|
+
except PermissionError as exc:
|
|
216
|
+
raise ValueError('sem permissão para encerrar o PID do bridge; '
|
|
217
|
+
'nenhuma elevação foi solicitada') from exc
|
|
218
|
+
if proprio is not None:
|
|
219
|
+
try:
|
|
220
|
+
proprio.wait(timeout=6)
|
|
221
|
+
except subprocess.TimeoutExpired as exc:
|
|
222
|
+
raise ValueError('o bridge não encerrou após SIGTERM; '
|
|
223
|
+
'nenhum SIGKILL foi enviado') from exc
|
|
224
|
+
self.proc = None
|
|
225
|
+
return
|
|
226
|
+
limite = time.monotonic() + 6.0
|
|
227
|
+
while time.monotonic() < limite:
|
|
228
|
+
if self._status_atual().get('pid') != pid:
|
|
229
|
+
return
|
|
230
|
+
time.sleep(0.2)
|
|
231
|
+
raise ValueError('o bridge ainda responde após SIGTERM; nenhum SIGKILL foi enviado')
|
|
232
|
+
|
|
233
|
+
def tarefa_diagnosticar_porta(self):
|
|
234
|
+
if IS_WINDOWS:
|
|
235
|
+
return super().tarefa_diagnosticar_porta()
|
|
236
|
+
porta = _porta_bridge(painel.ler_config())
|
|
237
|
+
ss = shutil.which('ss')
|
|
238
|
+
lsof = None if ss else shutil.which('lsof')
|
|
239
|
+
if ss:
|
|
240
|
+
comando = [ss, '-ltnp', 'sport', '=', f':{porta}']
|
|
241
|
+
elif lsof:
|
|
242
|
+
comando = [lsof, '-nP', f'-iTCP:{porta}', '-sTCP:LISTEN']
|
|
243
|
+
else:
|
|
244
|
+
return ('aviso', 'instale iproute2 (ss) ou lsof para diagnosticar a porta')
|
|
245
|
+
pronto = subprocess.run(comando, capture_output=True, text=True, errors='replace',
|
|
246
|
+
timeout=10, check=False, shell=False)
|
|
247
|
+
normal = pronto.returncode == 0 or (bool(lsof) and pronto.returncode == 1)
|
|
248
|
+
texto = pronto.stdout if normal else (pronto.stderr or pronto.stdout)
|
|
249
|
+
linhas = [linha.rstrip() for linha in (texto or '').splitlines() if linha.strip()]
|
|
250
|
+
if not linhas:
|
|
251
|
+
linhas = [f'nenhum listener TCP visível na porta {porta}' if normal
|
|
252
|
+
else 'o diagnóstico falhou; confira ss/lsof no sistema']
|
|
253
|
+
if len(linhas) > 22:
|
|
254
|
+
linhas = linhas[:1] + ['…'] + linhas[-20:]
|
|
255
|
+
self.modal = {'titulo': f'Diagnóstico da porta {porta}',
|
|
256
|
+
'linhas': [Text(linha) for linha in linhas],
|
|
257
|
+
'dica': f'código {pronto.returncode} · nada foi encerrado · Enter fecha'}
|
|
258
|
+
return ('ok' if normal else 'aviso', 'diagnóstico pronto — veja o quadro')
|
|
259
|
+
|
|
260
|
+
def acao_firewall(self, arg: str = ''):
|
|
261
|
+
acao = (arg or '').strip().lower() or 'liberar'
|
|
262
|
+
if acao not in ('liberar', 'remover'):
|
|
263
|
+
self.avisar('uso: /firewall [liberar|remover]', 'aviso')
|
|
264
|
+
return
|
|
265
|
+
try:
|
|
266
|
+
porta = _porta_bridge(painel.ler_config())
|
|
267
|
+
if porta == 8767:
|
|
268
|
+
raise ValueError('a porta 8767 do terminal nunca é liberada pelo painel')
|
|
269
|
+
except ValueError as exc:
|
|
270
|
+
self.avisar(str(exc), 'erro')
|
|
271
|
+
return
|
|
272
|
+
if IS_WINDOWS:
|
|
273
|
+
return super().acao_firewall('remover' if acao == 'remover' else '')
|
|
274
|
+
if self.tarefa_ativa:
|
|
275
|
+
self.avisar('aguarde a tarefa atual terminar', 'aviso')
|
|
276
|
+
return
|
|
277
|
+
if not sys.stdin.isatty() or not sys.stdout.isatty():
|
|
278
|
+
self.avisar('/firewall exige uma PTY interativa; sudo recebe a senha diretamente', 'erro')
|
|
279
|
+
return
|
|
280
|
+
script = ROOT / 'ferramentas' / 'firewall_linux.sh'
|
|
281
|
+
if not script.is_file():
|
|
282
|
+
self.avisar('script ferramentas/firewall_linux.sh não encontrado', 'erro')
|
|
283
|
+
return
|
|
284
|
+
# Foreground, sem pipes, input, getpass ou shell=True: sudo é dono do prompt.
|
|
285
|
+
try:
|
|
286
|
+
pronto = subprocess.run(['bash', str(script), acao, str(porta)], check=False,
|
|
287
|
+
shell=False)
|
|
288
|
+
except (OSError, KeyboardInterrupt) as exc:
|
|
289
|
+
self.avisar(f'firewall não concluído ({type(exc).__name__})', 'aviso')
|
|
290
|
+
return
|
|
291
|
+
self.avisar('comando do firewall concluído' if pronto.returncode == 0
|
|
292
|
+
else f'firewall não alterado ou incompleto (código {pronto.returncode}); veja a PTY',
|
|
293
|
+
'ok' if pronto.returncode == 0 else 'aviso')
|
|
294
|
+
|
|
295
|
+
def _corrigir_textos_nativos(self):
|
|
296
|
+
# Corrige só a apresentação herdada; a implementação dos comandos é a mesma.
|
|
297
|
+
trocas = {
|
|
298
|
+
'liberar a rede local (já é automático; refaz)': 'firewall somente sob comando expresso',
|
|
299
|
+
'ligar o bridge (já liga sozinho ao abrir)': 'ligar o bridge independente da PTY',
|
|
300
|
+
'o painel libera a rede sozinho ao abrir (aceite o UAC); /firewall refaz quando precisar.':
|
|
301
|
+
'use /firewall explicitamente; nunca é automático e não libera o terminal.',
|
|
302
|
+
'abrir o dashboard web local no navegador': 'mostrar o link do dashboard local',
|
|
303
|
+
}
|
|
304
|
+
if self.modal:
|
|
305
|
+
for indice, linha in enumerate(self.modal.get('linhas', [])):
|
|
306
|
+
texto = linha.plain if isinstance(linha, Text) else str(linha)
|
|
307
|
+
for original, novo in trocas.items():
|
|
308
|
+
if original in texto:
|
|
309
|
+
texto = texto.replace(original, novo)
|
|
310
|
+
self.modal['linhas'][indice] = Text(texto)
|
|
311
|
+
|
|
312
|
+
def mostrar_ajuda(self, arg: str = ''):
|
|
313
|
+
super().mostrar_ajuda(arg)
|
|
314
|
+
self._corrigir_textos_nativos()
|
|
315
|
+
|
|
316
|
+
def mostrar_enderecos(self, arg: str = ''):
|
|
317
|
+
super().mostrar_enderecos(arg)
|
|
318
|
+
self._corrigir_textos_nativos()
|
|
319
|
+
|
|
320
|
+
def loop_repl(self):
|
|
321
|
+
self.modo = 'repl'
|
|
322
|
+
print('Painel Rich na PTY — /ajuda lista os comandos. '
|
|
323
|
+
'Sem autostart, navegador ou firewall automático; /iniciar é explícito. '
|
|
324
|
+
'Desconectar não encerra o bridge.')
|
|
325
|
+
try:
|
|
326
|
+
while not self.saindo:
|
|
327
|
+
console = Console(theme=painel.TEMA)
|
|
328
|
+
self.largura, self.altura = console.width, console.height
|
|
329
|
+
snap = self.coletor.ler() or self.coletor._coletar()
|
|
330
|
+
self._snap_visto = snap
|
|
331
|
+
for item in self.render(snap):
|
|
332
|
+
console.print(item)
|
|
333
|
+
console.print(self._texto_status_rich(snap))
|
|
334
|
+
try:
|
|
335
|
+
segredo = self.wizard and self.wizard.get('passo') in ('chave', 'segredo')
|
|
336
|
+
linha = getpass.getpass(' ▸ ', stream=sys.stdout) if segredo else input(' ▸ ')
|
|
337
|
+
except (EOFError, KeyboardInterrupt):
|
|
338
|
+
break
|
|
339
|
+
self.buf = linha
|
|
340
|
+
self.ao_enter()
|
|
341
|
+
finally:
|
|
342
|
+
self.saindo = True
|
|
343
|
+
self._dashboard_cancelar.set()
|
|
344
|
+
self._encerrar_com_o_painel()
|
|
345
|
+
if self.msg:
|
|
346
|
+
print(' · ' + self.msg[1])
|
|
347
|
+
print(DESCONEXAO)
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
def main(argv=None):
|
|
351
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
352
|
+
grupo = parser.add_mutually_exclusive_group()
|
|
353
|
+
grupo.add_argument('--repl', action='store_true', help='REPL Rich na PTY (padrão)')
|
|
354
|
+
grupo.add_argument('--once', action='store_true', help='retrato somente leitura e sai')
|
|
355
|
+
args = parser.parse_args(argv)
|
|
356
|
+
app = PainelWeb()
|
|
357
|
+
if args.once:
|
|
358
|
+
app.retrato_unico()
|
|
359
|
+
return 0
|
|
360
|
+
with _sinais_de_desconexao():
|
|
361
|
+
app.iniciar()
|
|
362
|
+
app.loop_repl()
|
|
363
|
+
return 0
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
if __name__ == '__main__':
|
|
367
|
+
raise SystemExit(main())
|