ferer
This commit is contained in:
+81
-3
@@ -11,6 +11,7 @@ REQ_FILE="$SCRIPT_DIR/requirements.txt"
|
||||
MAIN_SCRIPT="$SCRIPT_DIR/main.py"
|
||||
VENV_DIR="$SCRIPT_DIR/venv"
|
||||
LOG_FILE="$SCRIPT_DIR/log.txt"
|
||||
BIN_DIR="$SCRIPT_DIR/bin"
|
||||
|
||||
# Cores para output
|
||||
GREEN='\033[0;32m'
|
||||
@@ -74,11 +75,88 @@ fi
|
||||
log_info "Imagem 'botaoparaclicar.png' encontrada."
|
||||
|
||||
# 7. Instala/atualiza dependências
|
||||
# Usamos --force-reinstall para garantir que pacotes com extensões C
|
||||
# (opencv-python, numpy, Pillow) sejam recompilados para a arquitetura
|
||||
# da máquina atual, evitando erro de "Illegal instruction" ao copiar
|
||||
# o ambiente virtual de outro computador.
|
||||
log_info "Verificando dependências..."
|
||||
pip install -r "$REQ_FILE" --quiet
|
||||
pip install --upgrade --force-reinstall -r "$REQ_FILE" --quiet
|
||||
log_info "Dependências instaladas."
|
||||
|
||||
# 8. Executa o programa
|
||||
# 8. Garante Xvfb para servidores headless (sem DISPLAY)
|
||||
# Em servidores sem ambiente gráfico, o pyautogui precisa de um display.
|
||||
# Tentamos usar o Xvfb do sistema; se não existir, baixamos e extraímos
|
||||
# o pacote .deb localmente (sem sudo).
|
||||
setup_xvfb() {
|
||||
if command -v xvfb-run &>/dev/null && command -v Xvfb &>/dev/null; then
|
||||
log_info "Xvfb encontrado no sistema."
|
||||
return 0
|
||||
fi
|
||||
|
||||
log_warn "Xvfb não encontrado no sistema."
|
||||
|
||||
# Tenta baixar e extrair o pacote xvfb .deb localmente
|
||||
if command -v apt-get &>/dev/null && command -v dpkg &>/dev/null; then
|
||||
log_info "Tentando instalar Xvfb localmente (sem sudo)..."
|
||||
TMPDIR=$(mktemp -d)
|
||||
if apt-get download -o Dir::Cache::archives="$TMPDIR" xvfb 2>/dev/null; then
|
||||
DEB_FILE=$(find "$TMPDIR" -name 'xvfb_*.deb' | head -1)
|
||||
if [ -n "$DEB_FILE" ]; then
|
||||
mkdir -p "$BIN_DIR"
|
||||
# Extrai apenas os binários e bibliotecas necessárias
|
||||
dpkg -x "$DEB_FILE" "$TMPDIR/xvfb-extract" 2>/dev/null
|
||||
# Copia binários
|
||||
if [ -f "$TMPDIR/xvfb-extract/usr/bin/xvfb-run" ]; then
|
||||
cp "$TMPDIR/xvfb-extract/usr/bin/xvfb-run" "$BIN_DIR/"
|
||||
sed -i "s|exec Xvfb |exec $SCRIPT_DIR/bin/Xvfb |g" "$BIN_DIR/xvfb-run"
|
||||
log_info "xvfb-run embutido em '$BIN_DIR'."
|
||||
fi
|
||||
if [ -f "$TMPDIR/xvfb-extract/usr/bin/Xvfb" ]; then
|
||||
cp "$TMPDIR/xvfb-extract/usr/bin/Xvfb" "$BIN_DIR/"
|
||||
log_info "Xvfb embutido em '$BIN_DIR'."
|
||||
fi
|
||||
rm -rf "$TMPDIR"
|
||||
|
||||
if [ -f "$BIN_DIR/xvfb-run" ] && [ -f "$BIN_DIR/Xvfb" ]; then
|
||||
log_info "Xvfb instalado localmente com sucesso."
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
rm -rf "$TMPDIR"
|
||||
fi
|
||||
|
||||
log_error "Não foi possível instalar Xvfb automaticamente."
|
||||
log_error ""
|
||||
log_error "O computador não tem ambiente gráfico e o Xvfb é necessário."
|
||||
log_error "Instale manualmente com:"
|
||||
log_error " sudo apt install xvfb"
|
||||
return 1
|
||||
}
|
||||
|
||||
# 9. Executa o programa
|
||||
# Adiciona binários locais (Xvfb embutido) ao PATH
|
||||
export PATH="$BIN_DIR:$PATH"
|
||||
|
||||
RUNNER="python3"
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
log_info "Sem ambiente gráfico (DISPLAY não definido)."
|
||||
if setup_xvfb; then
|
||||
if [ -f "$BIN_DIR/xvfb-run" ] && [ -f "$BIN_DIR/Xvfb" ]; then
|
||||
# Usa o xvfb-run embutido que referencia o Xvfb local
|
||||
RUNNER="$BIN_DIR/xvfb-run -a"
|
||||
log_info "Usando Xvfb embutido (servidor X virtual)."
|
||||
else
|
||||
RUNNER="xvfb-run -a"
|
||||
log_info "Usando Xvfb do sistema (servidor X virtual)."
|
||||
fi
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
log_info "Ambiente gráfico detectado (DISPLAY=$DISPLAY)."
|
||||
fi
|
||||
|
||||
log_info "Iniciando programa..."
|
||||
echo "=============================================="
|
||||
python3 "$MAIN_SCRIPT"
|
||||
$RUNNER "$MAIN_SCRIPT"
|
||||
|
||||
@@ -452,3 +452,42 @@ Sistema interrompido pelo usuário (CTRL+C).
|
||||
[2026-09-07 12:46:06] Clique #9/10 | Total geral: 9
|
||||
[2026-09-07 12:46:06] [Sessão 1] Aguardando 8s até o próximo ciclo...
|
||||
[2026-09-07 12:46:12] Total de cliques realizados: 9
|
||||
[2026-09-07 13:36:01] Pressione CTRL+C para parar.
|
||||
[2026-09-07 13:36:01] Aguardando 10s antes do primeiro clique...
|
||||
[2026-09-07 13:36:11] Botão NÃO encontrado. Confiança: 0.28 (mín: 0.9)
|
||||
[2026-09-07 13:36:11] [Sessão 1] Botão não encontrado. Falhas: 1/3 | Total: 0
|
||||
[2026-09-07 13:36:11] [Sessão 1] Aguardando 24s até o próximo ciclo...
|
||||
[2026-09-07 13:36:35] Botão NÃO encontrado. Confiança: 0.28 (mín: 0.9)
|
||||
[2026-09-07 13:36:35] [Sessão 1] Botão não encontrado. Falhas: 2/3 | Total: 0
|
||||
[2026-09-07 13:36:35] [Sessão 1] Aguardando 25s até o próximo ciclo...
|
||||
[2026-09-07 13:37:01] Botão NÃO encontrado. Confiança: 0.28 (mín: 0.9)
|
||||
[2026-09-07 13:37:01] [Sessão 1] Botão não encontrado. Falhas: 3/3 | Total: 0
|
||||
[2026-09-07 13:37:01] ⚠ Máximo de falhas (3) atingido. Encerrando.
|
||||
[2026-09-07 13:37:01] Total de cliques realizados: 0
|
||||
[2026-09-07 14:57:40] Pressione CTRL+C para parar.
|
||||
[2026-09-07 14:57:40] Aguardando 10s antes do primeiro clique...
|
||||
[2026-09-07 14:57:44] Total de cliques realizados: 0
|
||||
[2026-09-07 16:24:52] Pressione CTRL+C para parar.
|
||||
[2026-09-07 16:24:52] Aguardando 10s antes do primeiro clique...
|
||||
[2026-09-07 16:25:02] Botão NÃO encontrado. Confiança: 0.00 (mín: 0.9)
|
||||
[2026-09-07 16:25:02] [Sessão 1] Botão não encontrado. Falhas: 1/3 | Total: 0
|
||||
[2026-09-07 16:25:02] [Sessão 1] Aguardando 20s até o próximo ciclo...
|
||||
[2026-09-07 16:25:22] Botão NÃO encontrado. Confiança: 0.00 (mín: 0.9)
|
||||
[2026-09-07 16:25:22] [Sessão 1] Botão não encontrado. Falhas: 2/3 | Total: 0
|
||||
[2026-09-07 16:25:22] [Sessão 1] Aguardando 25s até o próximo ciclo...
|
||||
[2026-09-07 16:25:47] Botão NÃO encontrado. Confiança: 0.00 (mín: 0.9)
|
||||
[2026-09-07 16:25:47] [Sessão 1] Botão não encontrado. Falhas: 3/3 | Total: 0
|
||||
[2026-09-07 16:25:47] ⚠ Máximo de falhas (3) atingido. Encerrando.
|
||||
[2026-09-07 16:25:47] Total de cliques realizados: 0
|
||||
[2026-09-07 16:26:27] Pressione CTRL+C para parar.
|
||||
[2026-09-07 16:26:27] Aguardando 10s antes do primeiro clique...
|
||||
[2026-09-07 16:26:37] Botão NÃO encontrado. Confiança: 0.00 (mín: 0.9)
|
||||
[2026-09-07 16:26:37] [Sessão 1] Botão não encontrado. Falhas: 1/3 | Total: 0
|
||||
[2026-09-07 16:26:37] [Sessão 1] Aguardando 18s até o próximo ciclo...
|
||||
[2026-09-07 16:26:55] Botão NÃO encontrado. Confiança: 0.00 (mín: 0.9)
|
||||
[2026-09-07 16:26:55] [Sessão 1] Botão não encontrado. Falhas: 2/3 | Total: 0
|
||||
[2026-09-07 16:26:55] [Sessão 1] Aguardando 19s até o próximo ciclo...
|
||||
[2026-09-07 16:27:14] Botão NÃO encontrado. Confiança: 0.00 (mín: 0.9)
|
||||
[2026-09-07 16:27:14] [Sessão 1] Botão não encontrado. Falhas: 3/3 | Total: 0
|
||||
[2026-09-07 16:27:14] ⚠ Máximo de falhas (3) atingido. Encerrando.
|
||||
[2026-09-07 16:27:14] Total de cliques realizados: 0
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
BIN
Binary file not shown.
Executable → Regular
BIN
Binary file not shown.
Executable → Regular
BIN
Binary file not shown.
Executable → Regular
BIN
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user