worker-automate-hub 0.5.799__py3-none-any.whl → 0.5.800__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.
@@ -84,7 +84,7 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
84
84
  # Fecha a instancia do emsys - caso esteja aberta
85
85
  await kill_all_emsys()
86
86
 
87
- app = Application(backend="win32").start("C:\\Rezende\\EMSys3\\EMSysFiscal.exe")
87
+ app = Application(backend="win32").start("C:\\Rezende\\EMSys3\\EMSysFiscal_39.exe")
88
88
  warnings.filterwarnings(
89
89
  "ignore",
90
90
  category=UserWarning,
@@ -202,6 +202,7 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
202
202
  saida_checkbox.click_input()
203
203
 
204
204
  console.print("Aguardar marcar caixa de saida")
205
+ # imagem = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\saida_marcada.png"
205
206
  imagem = "assets\\abertura_livros\\saida_marcada.png"
206
207
 
207
208
  tempo_limite = 600 # 10 minutos
@@ -338,6 +339,7 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
338
339
  await worker_sleep(5)
339
340
 
340
341
  console.print("Aguardar o término de carregar")
342
+ # imagem = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\livros_incluidos.png"
341
343
  imagem = "assets\\abertura_livros\\livros_incluidos.png"
342
344
 
343
345
  tempo_limite = 1200 # 20 minutos
@@ -558,7 +560,7 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
558
560
 
559
561
  console.print("Clicando no botão incluir apuração")
560
562
  # Clicar em incluir apuração
561
- # imagem = "assets\\abertura_livros\\btn_incluir_apuracao.png"
563
+ # imagem = r"C:\Users\automatehub\Documents\GitHub\worker-automate-hub\assets\abertura_livros\btn_incluir_apuracao.png"
562
564
  imagem = "assets\\abertura_livros\\btn_incluir_apuracao.png"
563
565
 
564
566
  # Tenta localizar a imagem na tela
@@ -567,36 +569,114 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
567
569
  )
568
570
 
569
571
  if localizacao:
570
- print(f"Imagem incluir apuração encontrado em: {localizacao}")
572
+ console.print(f"Imagem incluir apuração encontrado em: {localizacao}")
571
573
  pyautogui.moveTo(localizacao)
572
574
  pyautogui.click()
575
+ console.print("Botão incluir clicado com sucesso")
573
576
 
574
- await worker_sleep(10)
575
-
576
- imagem = "assets\\abertura_livros\\aviso_erro.png"
577
+ await worker_sleep(2)
577
578
 
578
- # Tenta localizar a imagem na tela
579
- localizacao_erro = pyautogui.locateCenterOnScreen(
580
- imagem, confidence=0.9
581
- )
582
-
583
- if localizacao_erro:
584
- return RpaRetornoProcessoDTO(
585
- sucesso=False,
586
- retorno=f"Erro ao Incluir apuração, situação diferente de confirmado.",
587
- status=RpaHistoricoStatusEnum.Falha,
588
- tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)],
589
- )
579
+ desk = Desktop(backend="win32")
580
+ dlg = None
581
+ t_end = time.time() + 8.0 # até 8s procurando a janela
582
+ while time.time() < t_end:
583
+ try:
584
+ # variações: Aviso | Atenção | Erro
585
+ wins = desk.windows(title_re=".*(Aviso|Aten[cç][aã]o|Erro).*", visible_only=True)
586
+ if wins:
587
+ dlg = wins[0]
588
+ break
589
+ except Exception:
590
+ pass
591
+ time.sleep(0.25)
592
+
593
+ if dlg:
594
+ console.print("Janela 'Aviso' detectada. Capturando texto e screenshot...")
595
+
596
+ # === 2) Captura de screenshot da janela ===
597
+ try:
598
+ # pasta de prints (ajuste se quiser outra)
599
+ prints_dir = os.path.join(os.getcwd(), "prints")
600
+ os.makedirs(prints_dir, exist_ok=True)
601
+ ts = datetime.now().strftime("%Y%m%d_%H%M%S")
602
+ screenshot_path = os.path.join(prints_dir, f"aviso_{ts}.png")
603
+ dlg.set_focus()
604
+ img = dlg.capture_as_image()
605
+ img.save(screenshot_path)
606
+ console.print(f"Screenshot salvo: {screenshot_path}")
607
+ except Exception as e:
608
+ screenshot_path = None
609
+ console.print(f"Falha ao salvar screenshot do 'Aviso': {e}")
610
+
611
+ # === 3) Lê todo o texto da janela ===
612
+ texto_aviso = ""
613
+ try:
614
+ partes = []
615
+ for ctrl in dlg.descendants():
616
+ try:
617
+ t = ctrl.window_text()
618
+ if t and t.strip():
619
+ partes.append(t.strip())
620
+ except Exception:
621
+ pass
622
+ texto_aviso = " ".join(dict.fromkeys(partes)) # remove duplicados mantendo ordem
623
+ console.print(f"Texto do Aviso: {texto_aviso}")
624
+ except Exception as e:
625
+ console.print(f"Falha ao coletar texto do 'Aviso': {e}")
626
+
627
+ # === 4) Validação do conteúdo (edite/adicione frases-chave conforme seu caso) ===
628
+ FRASES_ERRO = [
629
+ "O período para apuração informado",
630
+ "situação diferente de confirmado",
631
+ ]
632
+
633
+ contem_msg_erro = any(frase.lower() in texto_aviso.lower() for frase in FRASES_ERRO)
634
+
635
+ if contem_msg_erro:
636
+ console.print("Confirmação de erro pelo texto da janela 'Aviso'. Retornando falha.")
637
+ retorno_msg = "Erro ao Incluir apuração."
638
+ if texto_aviso:
639
+ retorno_msg += f" Detalhe: {texto_aviso}"
640
+ if screenshot_path:
641
+ retorno_msg += f" | Print: {screenshot_path}"
642
+
643
+ return RpaRetornoProcessoDTO(
644
+ sucesso=False,
645
+ retorno=retorno_msg,
646
+ status=RpaHistoricoStatusEnum.Falha,
647
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)],
648
+ )
649
+ else:
650
+ console.print("Janela 'Aviso' não contém mensagem de erro mapeada. Seguindo fluxo.")
651
+ # (Opcional) você pode clicar no 'OK' e continuar:
652
+ try:
653
+ # tenta clicar em botão OK se existir
654
+ for c in dlg.descendants():
655
+ try:
656
+ if c.window_text().strip().lower() in ("ok", "&ok"):
657
+ c.click_input()
658
+ break
659
+ except Exception:
660
+ pass
661
+ except Exception:
662
+ pass
663
+ # não retorna aqui; deixa seguir para sucesso
664
+
665
+ # === 5) Se não houve 'Aviso' com erro mapeado, considera sucesso ===
666
+ console.print("Nenhum erro confirmado. Fluxo OK.")
667
+ try:
668
+ main_window.close()
669
+ console.print("Janela principal fechada.")
670
+ except Exception as e:
671
+ console.print(f"Falha ao fechar janela principal (ignorado): {e}")
590
672
 
591
- main_window.close()
592
-
593
- console.print("Apuração incluida com sucesso")
594
- retorno = "Apuração incluida com sucesso"
673
+ retorno = "Apuração incluída com sucesso"
595
674
  return RpaRetornoProcessoDTO(
596
- sucesso=True, retorno=retorno, status=RpaHistoricoStatusEnum.Sucesso
675
+ sucesso=True,
676
+ retorno=retorno,
677
+ status=RpaHistoricoStatusEnum.Sucesso,
597
678
  )
598
- else:
599
- console.print("Imagem incluir apuração não encontrada na tela.")
679
+
600
680
 
601
681
  except Exception as erro:
602
682
 
@@ -607,3 +687,4 @@ async def abertura_livros_fiscais(task: RpaProcessoEntradaDTO) -> RpaRetornoProc
607
687
  status=RpaHistoricoStatusEnum.Falha,
608
688
  tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
609
689
  )
690
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: worker-automate-hub
3
- Version: 0.5.799
3
+ Version: 0.5.800
4
4
  Summary: Worker Automate HUB é uma aplicação para automatizar rotinas de RPA nos ambientes Argenta.
5
5
  Author: Joel Paim
6
6
  Requires-Python: >=3.12,<4.0
@@ -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=zDp4kxspMYmsq1OnSyZr6kYqJt6ajGRiucz1f62KHz4,23081
39
+ worker_automate_hub/tasks/jobs/abertura_livros_fiscais.py,sha256=o-_z0GUpjj6iJpTk9O-gHkysgqJq4BYlUaGw9xjUH24,27528
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.799.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
107
- worker_automate_hub-0.5.799.dist-info/METADATA,sha256=WwW5bb159GaBzTtHvsu3mHUdjUFXI1_gagjyWcl4Xaw,3100
108
- worker_automate_hub-0.5.799.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
109
- worker_automate_hub-0.5.799.dist-info/RECORD,,
106
+ worker_automate_hub-0.5.800.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
107
+ worker_automate_hub-0.5.800.dist-info/METADATA,sha256=F5s6rBWJTDUhoynEMWT_yC3dorU81FogM-Ovyz4fs8s,3100
108
+ worker_automate_hub-0.5.800.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
109
+ worker_automate_hub-0.5.800.dist-info/RECORD,,