worker-automate-hub 0.5.799__py3-none-any.whl → 0.5.801__py3-none-any.whl
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.
- worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py +117 -27
- {worker_automate_hub-0.5.799.dist-info → worker_automate_hub-0.5.801.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.799.dist-info → worker_automate_hub-0.5.801.dist-info}/RECORD +5 -5
- {worker_automate_hub-0.5.799.dist-info → worker_automate_hub-0.5.801.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.799.dist-info → worker_automate_hub-0.5.801.dist-info}/entry_points.txt +0 -0
@@ -7,6 +7,7 @@ import sys
|
|
7
7
|
import os
|
8
8
|
from pywinauto.findwindows import ElementNotFoundError
|
9
9
|
from pywinauto.keyboard import send_keys
|
10
|
+
|
10
11
|
# sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
|
11
12
|
from worker_automate_hub.utils.logger import logger
|
12
13
|
from worker_automate_hub.models.dto.rpa_historico_request_dto import (
|
@@ -202,6 +203,7 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
202
203
|
saida_checkbox.click_input()
|
203
204
|
|
204
205
|
console.print("Aguardar marcar caixa de saida")
|
206
|
+
# imagem = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\saida_marcada.png"
|
205
207
|
imagem = "assets\\abertura_livros\\saida_marcada.png"
|
206
208
|
|
207
209
|
tempo_limite = 600 # 10 minutos
|
@@ -338,6 +340,7 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
338
340
|
await worker_sleep(5)
|
339
341
|
|
340
342
|
console.print("Aguardar o término de carregar")
|
343
|
+
# imagem = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\livros_incluidos.png"
|
341
344
|
imagem = "assets\\abertura_livros\\livros_incluidos.png"
|
342
345
|
|
343
346
|
tempo_limite = 1200 # 20 minutos
|
@@ -558,45 +561,132 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
|
|
558
561
|
|
559
562
|
console.print("Clicando no botão incluir apuração")
|
560
563
|
# Clicar em incluir apuração
|
561
|
-
# imagem = "assets
|
564
|
+
# imagem = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\btn_incluir_apuracao.png"
|
562
565
|
imagem = "assets\\abertura_livros\\btn_incluir_apuracao.png"
|
563
566
|
|
564
567
|
# Tenta localizar a imagem na tela
|
565
|
-
localizacao = pyautogui.locateCenterOnScreen(
|
566
|
-
|
567
|
-
)
|
568
|
-
|
568
|
+
localizacao = pyautogui.locateCenterOnScreen(imagem, confidence=0.9)
|
569
|
+
|
569
570
|
if localizacao:
|
570
|
-
print(f"Imagem incluir apuração encontrado em: {localizacao}")
|
571
|
+
console.print(f"Imagem incluir apuração encontrado em: {localizacao}")
|
571
572
|
pyautogui.moveTo(localizacao)
|
572
573
|
pyautogui.click()
|
574
|
+
console.print("Botão incluir clicado com sucesso")
|
573
575
|
|
574
|
-
await worker_sleep(
|
576
|
+
await worker_sleep(2)
|
575
577
|
|
576
|
-
|
578
|
+
desk = Desktop(backend="win32")
|
579
|
+
dlg = None
|
580
|
+
t_end = time.time() + 8.0 # até 8s procurando a janela
|
581
|
+
while time.time() < t_end:
|
582
|
+
try:
|
583
|
+
# variações: Aviso | Atenção | Erro
|
584
|
+
wins = desk.windows(
|
585
|
+
title_re=".*(Aviso|Aten[cç][aã]o|Erro).*", visible_only=True
|
586
|
+
)
|
587
|
+
if wins:
|
588
|
+
dlg = wins[0]
|
589
|
+
break
|
590
|
+
except Exception:
|
591
|
+
pass
|
592
|
+
time.sleep(0.25)
|
593
|
+
|
594
|
+
if dlg:
|
595
|
+
console.print(
|
596
|
+
"Janela 'Aviso' detectada. Capturando texto e screenshot..."
|
597
|
+
)
|
577
598
|
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
599
|
+
# === 2) Captura de screenshot da janela ===
|
600
|
+
try:
|
601
|
+
# pasta de prints (ajuste se quiser outra)
|
602
|
+
prints_dir = os.path.join(os.getcwd(), "prints")
|
603
|
+
os.makedirs(prints_dir, exist_ok=True)
|
604
|
+
ts = datetime.now().strftime("%Y%m%d_%H%M%S")
|
605
|
+
screenshot_path = os.path.join(prints_dir, f"aviso_{ts}.png")
|
606
|
+
dlg.set_focus()
|
607
|
+
img = dlg.capture_as_image()
|
608
|
+
img.save(screenshot_path)
|
609
|
+
console.print(f"Screenshot salvo: {screenshot_path}")
|
610
|
+
except Exception as e:
|
611
|
+
screenshot_path = None
|
612
|
+
console.print(f"Falha ao salvar screenshot do 'Aviso': {e}")
|
613
|
+
|
614
|
+
# === 3) Lê todo o texto da janela ===
|
615
|
+
texto_aviso = ""
|
616
|
+
try:
|
617
|
+
partes = []
|
618
|
+
for ctrl in dlg.descendants():
|
619
|
+
try:
|
620
|
+
t = ctrl.window_text()
|
621
|
+
if t and t.strip():
|
622
|
+
partes.append(t.strip())
|
623
|
+
except Exception:
|
624
|
+
pass
|
625
|
+
texto_aviso = " ".join(
|
626
|
+
dict.fromkeys(partes)
|
627
|
+
) # remove duplicados mantendo ordem
|
628
|
+
console.print(f"Texto do Aviso: {texto_aviso}")
|
629
|
+
except Exception as e:
|
630
|
+
console.print(f"Falha ao coletar texto do 'Aviso': {e}")
|
631
|
+
|
632
|
+
# === 4) Validação do conteúdo (edite/adicione frases-chave conforme seu caso) ===
|
633
|
+
FRASES_ERRO = [
|
634
|
+
"O período para apuração informado",
|
635
|
+
"situação diferente de confirmado",
|
636
|
+
]
|
637
|
+
|
638
|
+
contem_msg_erro = any(
|
639
|
+
frase.lower() in texto_aviso.lower() for frase in FRASES_ERRO
|
640
|
+
)
|
641
|
+
|
642
|
+
if contem_msg_erro:
|
643
|
+
console.print(
|
644
|
+
"Confirmação de erro pelo texto da janela 'Aviso'. Retornando falha."
|
645
|
+
)
|
646
|
+
retorno_msg = "Erro ao Incluir apuração."
|
647
|
+
if texto_aviso:
|
648
|
+
retorno_msg += f" Detalhe: {texto_aviso}"
|
649
|
+
if screenshot_path:
|
650
|
+
retorno_msg += f" | Print: {screenshot_path}"
|
651
|
+
|
652
|
+
return RpaRetornoProcessoDTO(
|
653
|
+
sucesso=False,
|
654
|
+
retorno=retorno_msg,
|
655
|
+
status=RpaHistoricoStatusEnum.Falha,
|
656
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)],
|
657
|
+
)
|
658
|
+
else:
|
659
|
+
console.print(
|
660
|
+
"Janela 'Aviso' não contém mensagem de erro mapeada. Seguindo fluxo."
|
661
|
+
)
|
662
|
+
# (Opcional) você pode clicar no 'OK' e continuar:
|
663
|
+
try:
|
664
|
+
# tenta clicar em botão OK se existir
|
665
|
+
for c in dlg.descendants():
|
666
|
+
try:
|
667
|
+
if c.window_text().strip().lower() in ("ok", "&ok"):
|
668
|
+
c.click_input()
|
669
|
+
break
|
670
|
+
except Exception:
|
671
|
+
pass
|
672
|
+
except Exception:
|
673
|
+
pass
|
674
|
+
# não retorna aqui; deixa seguir para sucesso
|
675
|
+
|
676
|
+
# === 5) Se não houve 'Aviso' com erro mapeado, considera sucesso ===
|
677
|
+
console.print("Nenhum erro confirmado. Fluxo OK.")
|
678
|
+
try:
|
679
|
+
main_window.close()
|
680
|
+
console.print("Janela principal fechada.")
|
681
|
+
except Exception as e:
|
682
|
+
console.print(f"Falha ao fechar janela principal (ignorado): {e}")
|
590
683
|
|
591
|
-
|
592
|
-
|
593
|
-
console.print("Apuração incluida com sucesso")
|
594
|
-
retorno = "Apuração incluida com sucesso"
|
684
|
+
retorno = "Apuração incluída com sucesso"
|
595
685
|
return RpaRetornoProcessoDTO(
|
596
|
-
sucesso=True,
|
686
|
+
sucesso=True,
|
687
|
+
retorno=retorno,
|
688
|
+
status=RpaHistoricoStatusEnum.Sucesso,
|
597
689
|
)
|
598
|
-
else:
|
599
|
-
console.print("Imagem incluir apuração não encontrada na tela.")
|
600
690
|
|
601
691
|
except Exception as erro:
|
602
692
|
|
@@ -36,7 +36,7 @@ worker_automate_hub/models/dto/rpa_sap_dto.py,sha256=eovdvKCtVIhRct3PL98KjsdlngL
|
|
36
36
|
worker_automate_hub/models/dto/rpa_sistema_dto.py,sha256=sLkmJei8x6sl-1-IXUKDmYQuKx0sotYQREPyhQqPmRg,161
|
37
37
|
worker_automate_hub/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
38
38
|
worker_automate_hub/tasks/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
39
|
-
worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py,sha256=
|
39
|
+
worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py,sha256=Ldh1IuxrdDizkTvQRj91IC-I3ubhJ7dDNaTaAso0q8Y,27800
|
40
40
|
worker_automate_hub/tasks/jobs/coleta_dje_process.py,sha256=UkLWTC5Ub2qBb0yY-8IZ0DLLOVJOfNTq_z9krx_t25Q,29476
|
41
41
|
worker_automate_hub/tasks/jobs/conexao_rdp.py,sha256=S6QC4xhuo0pB5FjaUJZNMm1LIgEjpjifReCTBDqxH-U,11719
|
42
42
|
worker_automate_hub/tasks/jobs/cte_manual.py,sha256=JucHpRMjMiy-QEJ0wtFnytLpN53tKXgCDI05nGLGclU,603
|
@@ -103,7 +103,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
|
|
103
103
|
worker_automate_hub/utils/util.py,sha256=noQRUSAjRnoDb1c4iMZ5eoyrNp59a8T9K78MHhalASw,210255
|
104
104
|
worker_automate_hub/utils/utils_nfe_entrada.py,sha256=F7jk95LpDwl5WfaQXahCA5yDdnySnWdctDqczHXwGqE,38195
|
105
105
|
worker_automate_hub/worker.py,sha256=zEnYUrm5kY2cHbbee15QJkwkx4euD2SB2zRvUIbjS90,6850
|
106
|
-
worker_automate_hub-0.5.
|
107
|
-
worker_automate_hub-0.5.
|
108
|
-
worker_automate_hub-0.5.
|
109
|
-
worker_automate_hub-0.5.
|
106
|
+
worker_automate_hub-0.5.801.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
107
|
+
worker_automate_hub-0.5.801.dist-info/METADATA,sha256=eEB2-yI8bOkLhHqeeDvla_2kq0gPKjv7xaAsfUhbKDs,3100
|
108
|
+
worker_automate_hub-0.5.801.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
109
|
+
worker_automate_hub-0.5.801.dist-info/RECORD,,
|
File without changes
|
{worker_automate_hub-0.5.799.dist-info → worker_automate_hub-0.5.801.dist-info}/entry_points.txt
RENAMED
File without changes
|