worker-automate-hub 0.5.334__py3-none-any.whl → 0.5.335__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.
@@ -13,7 +13,6 @@ import xml.etree.ElementTree as ET
13
13
  from datetime import datetime, timedelta
14
14
  from pathlib import Path
15
15
  from typing import Dict, TypedDict
16
- import time
17
16
 
18
17
  import aiohttp
19
18
  import cv2
@@ -2536,75 +2535,139 @@ async def error_before_persist_record() -> RpaRetornoProcessoDTO:
2536
2535
  except:
2537
2536
  console.print("Erro ao capturar mensagem de erro")
2538
2537
 
2539
- async def wait_for_window(app, window_name: str, timeout: int, interval: float = 1.0):
2540
- start = time.time()
2541
- while time.time() - start < timeout:
2542
- try:
2543
- window = app[window_name]
2544
- if window.exists():
2545
- return window
2546
- except Exception:
2547
- pass
2548
- await worker_sleep(interval)
2549
- return None
2550
-
2551
- async def wait_for_window_open_by_class(class_name: str, window_name: str, timeout: int, interval: float = 1.0):
2552
- start = time.time()
2553
- while time.time() - start < timeout:
2554
- result = await is_window_open_by_class(class_name, window_name)
2555
- if result["IsOpened"]:
2556
- return True
2557
- await worker_sleep(interval)
2558
- return False
2559
2538
 
2560
2539
  async def itens_not_found_supplier(xml: str) -> RpaRetornoProcessoDTO:
2561
2540
  try:
2562
2541
  username = getpass.getuser()
2563
2542
  console.print("Verificando se existe tela de multiplas referencias.\n")
2564
2543
  await worker_sleep(10)
2565
- itens_fornecedor = await is_window_open_by_class("TFrmSelecionaItensFornecedor", "TFrmSelecionaItensFornecedor")
2566
- if itens_fornecedor["IsOpened"]:
2544
+
2545
+ itens_fornecedor = await is_window_open_by_class(
2546
+ "TFrmSelecionaItensFornecedor", "TFrmSelecionaItensFornecedor"
2547
+ )
2548
+
2549
+ if itens_fornecedor["IsOpened"] == True:
2567
2550
  console.print("Tela de multiplas referencias existe.\n")
2568
2551
  return RpaRetornoProcessoDTO(
2569
2552
  sucesso=False,
2570
2553
  retorno="Tela de Itens fornecedor - Multiplas referencias",
2571
2554
  status=RpaHistoricoStatusEnum.Falha,
2572
- tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)]
2555
+ tags=[RpaTagDTO(descricao=RpaTagEnum.Negocio)],
2573
2556
  )
2557
+
2574
2558
  console.print("Iteragindo com a tela de itens não localizados // NCM ...\n")
2559
+
2575
2560
  app = Application().connect(class_name="TFrmAguarde", timeout=60)
2576
- aguarde_window = app.window(class_name="TFrmAguarde")
2577
- aguarde_window.wait_not("exists visible")
2578
- main_window = await wait_for_window(app, "TMessageForm", timeout=180, interval=3)
2579
- if not main_window:
2580
- return RpaRetornoProcessoDTO(
2581
- sucesso=True,
2582
- retorno="Tela de aguardar carregada - Seguindo com andamento do processo (NCM).",
2583
- status=RpaHistoricoStatusEnum.Sucesso,
2584
- )
2561
+
2562
+ max_attempts = 60
2563
+ i = 0
2564
+
2565
+ while i < max_attempts:
2566
+ try:
2567
+ main_window = app["TMessageForm"]
2568
+ console.print("Janela 'TMessageForm' encontrada!")
2569
+ break
2570
+ except Exception as e:
2571
+ console.print(f"Erro ao tentar acessar TMessageForm: {e}")
2572
+ janela_aguarde = await is_window_open_by_class(
2573
+ "TFrmAguarde", "TFrmAguarde"
2574
+ )
2575
+ if janela_aguarde["IsOpened"] == True:
2576
+ console.print(
2577
+ "Aguardando tela de aguarde desaparecer ou conectar...\n"
2578
+ )
2579
+ else:
2580
+ try:
2581
+ main_window = app["TMessageForm"]
2582
+ if main_window.exists():
2583
+ console.print("Janela 'TMessageForm' encontrada!")
2584
+ break
2585
+ except:
2586
+ return RpaRetornoProcessoDTO(
2587
+ sucesso=True,
2588
+ retorno="Tela de aguardar carregada - Seguindo com andamento do processo (NCM).",
2589
+ status=RpaHistoricoStatusEnum.Sucesso,
2590
+ )
2591
+
2592
+ await worker_sleep(3)
2593
+ i += 1
2594
+
2585
2595
  window_title = main_window.window_text()
2596
+
2586
2597
  if "Confirm" in window_title or "Seleciona Itens Fornecedor" in window_title:
2587
2598
  console.print("Itens nao localizados para o fornecedor...\n")
2588
2599
  if main_window.exists():
2589
2600
  main_window.type_keys("%n")
2590
2601
  await worker_sleep(10)
2591
- console.print("Verificando a existencia de tela de selecionar Itens...\n")
2592
- itens_fornecedor = await is_window_open_by_class("TFrmSelecionaItensFornecedor", "TFrmSelecionaItensFornecedor")
2593
- if itens_fornecedor["IsOpened"]:
2602
+
2603
+ console.print(
2604
+ "Verificando a existencia de tela de selecionar Itens...\n"
2605
+ )
2606
+ itens_fornecedor = await is_window_open_by_class(
2607
+ "TFrmSelecionaItensFornecedor", "TFrmSelecionaItensFornecedor"
2608
+ )
2609
+
2610
+ if itens_fornecedor["IsOpened"] == True:
2594
2611
  return RpaRetornoProcessoDTO(
2595
2612
  sucesso=True,
2596
2613
  retorno="Tela de Itens fornecedor - Multiplas referencias",
2597
2614
  status=RpaHistoricoStatusEnum.Sucesso,
2598
2615
  )
2599
2616
  else:
2600
- console.print("Não possui a existencia de tela de selecionar Itens Fornecedor...\n")
2617
+ console.print(
2618
+ "Não possui a existencia de tela de selecionar Itens Fornecedor...\n"
2619
+ )
2620
+
2601
2621
  await worker_sleep(10)
2602
2622
  console.print("Verificando a existe da tela dos itens com erro...\n")
2603
- if await wait_for_window_open_by_class("TFrmExibeLogErroImportacaoNfe", "TFrmExibeLogErroImportacaoNfe", timeout=300, interval=5):
2604
- app = Application().connect(class_name="TFrmExibeLogErroImportacaoNfe")
2623
+
2624
+ max_attempts = 60
2625
+ i = 0
2626
+ while i < max_attempts:
2627
+ logs_erro = await is_window_open_by_class(
2628
+ "TFrmExibeLogErroImportacaoNfe", "TFrmExibeLogErroImportacaoNfe"
2629
+ )
2630
+ if logs_erro["IsOpened"] == True:
2631
+ break
2632
+ else:
2633
+ console.print(
2634
+ "Aguardando confirmação de tela de erro importação NFe...\n"
2635
+ )
2636
+ try:
2637
+ app = Application().connect(class_name="TFrmAguarde")
2638
+ main_window = app["TMessageForm"]
2639
+ console.print("Janela 'Information' encontrada!")
2640
+ window_title = main_window.window_text()
2641
+ if "Information" in window_title:
2642
+ main_window.type_keys("%n")
2643
+ else:
2644
+ console.print(
2645
+ "Não possui a existencia de 'Information'...\n"
2646
+ )
2647
+ except:
2648
+ console.print(
2649
+ "Não possui a existencia de tela de Information...\n"
2650
+ )
2651
+ await worker_sleep(5)
2652
+ i += 1
2653
+
2654
+ await worker_sleep(5)
2655
+ logs_erro = await is_window_open_by_class(
2656
+ "TFrmExibeLogErroImportacaoNfe", "TFrmExibeLogErroImportacaoNfe"
2657
+ )
2658
+ if logs_erro["IsOpened"] == True:
2659
+ app = Application().connect(
2660
+ class_name="TFrmExibeLogErroImportacaoNfe"
2661
+ )
2605
2662
  main_window = app["TFrmExibeLogErroImportacaoNfe"]
2606
- console.print("Tela com itens com erro existe, salvando os itens...\n")
2607
- btn_save = main_window.child_window(title="Salvar", class_name="TBitBtn")
2663
+ console.print(
2664
+ "Tela com itens com erro existe, salvando os itens...\n"
2665
+ )
2666
+
2667
+ btn_save = main_window.child_window(
2668
+ title="Salvar", class_name="TBitBtn"
2669
+ )
2670
+
2608
2671
  if btn_save.exists():
2609
2672
  max_attempts = 3
2610
2673
  i = 0
@@ -2613,17 +2676,25 @@ async def itens_not_found_supplier(xml: str) -> RpaRetornoProcessoDTO:
2613
2676
  try:
2614
2677
  btn_save.click()
2615
2678
  except:
2616
- console.print("Não foi possivel clicar no Botão OK... \n")
2679
+ console.print(
2680
+ "Não foi possivel clicar no Botão OK... \n"
2681
+ )
2617
2682
  await worker_sleep(3)
2618
- console.print("Verificando a existencia da tela 'Salvar'...\n")
2683
+
2684
+ console.print(
2685
+ "Verificando a existencia da tela 'Salvar'...\n"
2686
+ )
2619
2687
  try:
2620
2688
  app = Application().connect(title="Salvar")
2621
2689
  main_window = app["Salvar"]
2622
2690
  console.print("Tela 'Salvar' encontrada!")
2623
2691
  break
2624
2692
  except Exception as e:
2625
- console.print(f"Tela 'Salvar' não encontrada. Tentativa {i + 1}/{max_attempts}.")
2693
+ console.print(
2694
+ f"Tela 'Salvar' não encontrada. Tentativa {i + 1}/{max_attempts}."
2695
+ )
2626
2696
  i += 1
2697
+
2627
2698
  if i == max_attempts:
2628
2699
  return RpaRetornoProcessoDTO(
2629
2700
  sucesso=False,
@@ -2631,20 +2702,31 @@ async def itens_not_found_supplier(xml: str) -> RpaRetornoProcessoDTO:
2631
2702
  status=RpaHistoricoStatusEnum.Falha,
2632
2703
  tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
2633
2704
  )
2705
+
2634
2706
  await worker_sleep(4)
2635
2707
  console.print("Interagindo com a tela 'Salvar'...\n")
2636
- path_to_txt = f"C:\\Users\\{username}\\Downloads\\erro_itens{xml}.txt"
2708
+ path_to_txt = (
2709
+ f"C:\\Users\\{username}\\Downloads\\erro_itens{xml}.txt"
2710
+ )
2711
+
2637
2712
  main_window.type_keys("%n")
2638
2713
  pyautogui.write(path_to_txt)
2639
2714
  await worker_sleep(1)
2640
2715
  main_window.type_keys("%l")
2641
2716
  console.print("Arquivo salvo com sucesso...\n")
2717
+
2642
2718
  await worker_sleep(3)
2643
- with open(path_to_txt, "r", encoding="latin1", errors="replace") as arquivo:
2719
+ with open(
2720
+ path_to_txt, "r", encoding="latin1", errors="replace"
2721
+ ) as arquivo:
2644
2722
  conteudo = arquivo.read()
2645
- console.print(f"Arquivo salvo com sucesso, itens com erro {conteudo}...\n")
2723
+ console.print(
2724
+ f"Arquivo salvo com sucesso, itens com erro {conteudo}...\n"
2725
+ )
2726
+
2646
2727
  os.remove(path_to_txt)
2647
2728
  console.print("Removendo o arquivo...\n")
2729
+
2648
2730
  return RpaRetornoProcessoDTO(
2649
2731
  sucesso=False,
2650
2732
  retorno=f"Itens nao localizados p/ fornecedor. Mensagem: {conteudo}",
@@ -2658,6 +2740,7 @@ async def itens_not_found_supplier(xml: str) -> RpaRetornoProcessoDTO:
2658
2740
  status=RpaHistoricoStatusEnum.Falha,
2659
2741
  tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
2660
2742
  )
2743
+
2661
2744
  else:
2662
2745
  return RpaRetornoProcessoDTO(
2663
2746
  sucesso=False,
@@ -2672,6 +2755,7 @@ async def itens_not_found_supplier(xml: str) -> RpaRetornoProcessoDTO:
2672
2755
  status=RpaHistoricoStatusEnum.Falha,
2673
2756
  tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
2674
2757
  )
2758
+
2675
2759
  elif "Information" in window_title:
2676
2760
  console.print("Tela de NCM para o fornecedor...\n")
2677
2761
  if main_window.exists():
@@ -2682,11 +2766,13 @@ async def itens_not_found_supplier(xml: str) -> RpaRetornoProcessoDTO:
2682
2766
  retorno="Tela de NCM - clicado em NO para andamento do processo",
2683
2767
  status=RpaHistoricoStatusEnum.Sucesso,
2684
2768
  )
2769
+
2685
2770
  return RpaRetornoProcessoDTO(
2686
2771
  sucesso=True,
2687
2772
  retorno="Tela TMessageForm sem Title match. Seguindo...",
2688
2773
  status=RpaHistoricoStatusEnum.Sucesso,
2689
2774
  )
2775
+
2690
2776
  except Exception as e:
2691
2777
  return RpaRetornoProcessoDTO(
2692
2778
  sucesso=False,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: worker-automate-hub
3
- Version: 0.5.334
3
+ Version: 0.5.335
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
@@ -56,7 +56,7 @@ worker_automate_hub/tasks/jobs/entrada_de_notas_32.py,sha256=yXi9xb7V1Gb_312zZ5c
56
56
  worker_automate_hub/tasks/jobs/entrada_de_notas_33.py,sha256=YTRvZ59C--VqIJHF-T6HQr2PFoGEnoIvuWJMY8P19Y8,33607
57
57
  worker_automate_hub/tasks/jobs/entrada_de_notas_34.py,sha256=79DgSzDvc9GDFo1ah1jPeh7SU8pIgkhU-fFIJnE_9Q8,33369
58
58
  worker_automate_hub/tasks/jobs/entrada_de_notas_36.py,sha256=LW44NTCZJ_N5FCF5i4DRzG4GPdGEA3q_VJ1qJbH5omQ,34635
59
- worker_automate_hub/tasks/jobs/entrada_de_notas_39.py,sha256=UXlHTQfl5tNkwkJW3VTNMzW_JizLK47ixB-1-R6nkYE,142815
59
+ worker_automate_hub/tasks/jobs/entrada_de_notas_39.py,sha256=pLHP6EMUoPz5k4D3XmN5tKQmd1cyFx0awCaGqri5sOs,46797
60
60
  worker_automate_hub/tasks/jobs/entrada_de_notas_500.py,sha256=noYUpsq8qyiAhR6FvzEJGT8WTUZuWJtJoPhM6mvs4CI,44162
61
61
  worker_automate_hub/tasks/jobs/entrada_de_notas_505.py,sha256=xXeNipdXTSll8yAtAmN7v0sjN3oMlWU4THu30mKDddc,30339
62
62
  worker_automate_hub/tasks/jobs/entrada_de_notas_7139.py,sha256=aSgHterguK9XGtq0Bf__YlXo5pewb9P-BRZTLnrH1D8,29020
@@ -82,10 +82,10 @@ worker_automate_hub/utils/get_creds_gworkspace.py,sha256=ZJ0IIEjM4IXIV9rwfbOZ1V1
82
82
  worker_automate_hub/utils/logger.py,sha256=FYV9fg0_RAYJF_ZOCJEbqQAiCXlXk2gMpvUU1rzT_xs,671
83
83
  worker_automate_hub/utils/toast.py,sha256=xPHc5r5uOxB_cZlCzm13Kt2qSKLLFZALncU6Qg3Ft68,1162
84
84
  worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbVlwDl49Y,7972
85
- worker_automate_hub/utils/util.py,sha256=sadsyNEdhkhMHU2jVdDCJK59kHd4TWVDmmfQ62gc5Q8,182626
85
+ worker_automate_hub/utils/util.py,sha256=WZK1VjdoOCHWWXzLt9gh2uUi_6p3OfvI6DvAYIGi998,185072
86
86
  worker_automate_hub/utils/utils_nfe_entrada.py,sha256=wmnpuOesmPSryZszmapa37b9YNC0E2MkeDYnbwr-0rU,33315
87
87
  worker_automate_hub/worker.py,sha256=axdrr1xLTjWEyWfcyH3OCSpPTsyzck_fL_0u1DBLjvw,6525
88
- worker_automate_hub-0.5.334.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
89
- worker_automate_hub-0.5.334.dist-info/METADATA,sha256=MuBbqvKwUKOOsK8jE-KYHrwmrL5kOj7Tm9v04psOfg0,3041
90
- worker_automate_hub-0.5.334.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
91
- worker_automate_hub-0.5.334.dist-info/RECORD,,
88
+ worker_automate_hub-0.5.335.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
89
+ worker_automate_hub-0.5.335.dist-info/METADATA,sha256=ZzffX22N1dmXmjvSxwWECX0pvR4iDtfi8Cif7djeXFo,3041
90
+ worker_automate_hub-0.5.335.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
91
+ worker_automate_hub-0.5.335.dist-info/RECORD,,