worker-automate-hub 0.5.53__py3-none-any.whl → 0.5.54__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.
Potentially problematic release.
This version of worker-automate-hub might be problematic. Click here for more details.
- worker_automate_hub/api/webhook_service.py +5 -1
- worker_automate_hub/tasks/jobs/devolucao_prazo_a_faturar.py +34 -12
- worker_automate_hub/tasks/task_executor.py +5 -1
- worker_automate_hub/utils/util.py +103 -18
- {worker_automate_hub-0.5.53.dist-info → worker_automate_hub-0.5.54.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.53.dist-info → worker_automate_hub-0.5.54.dist-info}/RECORD +8 -8
- {worker_automate_hub-0.5.53.dist-info → worker_automate_hub-0.5.54.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.53.dist-info → worker_automate_hub-0.5.54.dist-info}/entry_points.txt +0 -0
@@ -8,7 +8,8 @@ console = Console()
|
|
8
8
|
async def send_to_webhook(
|
9
9
|
url_retorno: str,
|
10
10
|
status: str,
|
11
|
-
observacao: str
|
11
|
+
observacao: str,
|
12
|
+
identificador_webhook: str = None
|
12
13
|
) -> None:
|
13
14
|
"""
|
14
15
|
Envia uma notificacao para o endpoint do webhook passado como parametro.
|
@@ -35,6 +36,9 @@ async def send_to_webhook(
|
|
35
36
|
"observacao": observacao,
|
36
37
|
}
|
37
38
|
|
39
|
+
if identificador_webhook:
|
40
|
+
data["identificador"] = identificador_webhook
|
41
|
+
|
38
42
|
try:
|
39
43
|
async with aiohttp.ClientSession(
|
40
44
|
connector=aiohttp.TCPConnector(verify_ssl=False)
|
@@ -35,6 +35,7 @@ from worker_automate_hub.utils.util import (
|
|
35
35
|
e_ultimo_dia_util,
|
36
36
|
delete_xml,
|
37
37
|
ocr_warnings,
|
38
|
+
ocr_by_class,
|
38
39
|
nf_busca_nf_saida,
|
39
40
|
pessoas_ativa_cliente_fornecedor,
|
40
41
|
nf_devolucao_liquidar_cupom,
|
@@ -758,9 +759,7 @@ async def devolucao_prazo_a_faturar(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
758
759
|
console.print(f"Imagem preparada com sucesso...\n")
|
759
760
|
console.print(f"Realizando OCR...\n")
|
760
761
|
captured_text = pytesseract.image_to_string(Image.open(path_to_png))
|
761
|
-
console.print(
|
762
|
-
f"Texto Full capturado {captured_text}...\n"
|
763
|
-
)
|
762
|
+
console.print(f"Texto Full capturado {captured_text}...\n")
|
764
763
|
os.remove(path_to_png)
|
765
764
|
pattern = r"sequ[êe]ncia:\s*(\d+)"
|
766
765
|
match = re.search(pattern, captured_text)
|
@@ -769,6 +768,9 @@ async def devolucao_prazo_a_faturar(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
769
768
|
numero_nota_fiscal = match.group(1)
|
770
769
|
|
771
770
|
|
771
|
+
app = Application().connect(title="Information", timeout=180)
|
772
|
+
main_window = app["Information"]
|
773
|
+
main_window.set_focus()
|
772
774
|
btn_ok = main_window.child_window(class_name="TButton", found_index=0)
|
773
775
|
btn_ok.click()
|
774
776
|
await worker_sleep(3)
|
@@ -819,17 +821,37 @@ async def devolucao_prazo_a_faturar(task: RpaProcessoEntradaDTO) -> RpaRetornoPr
|
|
819
821
|
|
820
822
|
while i < max_attempts:
|
821
823
|
try:
|
822
|
-
app = Application().connect(class_name="TFrmProcessamentoFEe2", timeout=
|
824
|
+
app = Application().connect(class_name="TFrmProcessamentoFEe2", timeout=10)
|
823
825
|
main_window = app["TFrmProcessamentoFEe2"]
|
824
826
|
|
825
|
-
await worker_sleep(
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
827
|
+
await worker_sleep(5)
|
828
|
+
information_pop_up = await is_window_open_by_class("TMessageForm", "TMessageForm")
|
829
|
+
if information_pop_up["IsOpened"] == True:
|
830
|
+
msg_pop_up = await ocr_by_class(numero_nota_fiscal, "TMessageForm", "TMessageForm")
|
831
|
+
if msg_pop_up.sucesso:
|
832
|
+
if 'operação concl' in msg_pop_up or 'operacao concl' in msg_pop_up:
|
833
|
+
information_operacao_concluida = main_window.child_window(class_name="TMessageForm")
|
834
|
+
btn_ok = information_operacao_concluida.child_window(class_name="TButton")
|
835
|
+
btn_ok.click()
|
836
|
+
await worker_sleep(4)
|
837
|
+
main_window.close()
|
838
|
+
break
|
839
|
+
else:
|
840
|
+
retorno = f"Pop up nao mapeado para seguimento do robo {msg_pop_up} \nEtapas Executadas:\n{steps}"
|
841
|
+
return RpaRetornoProcessoDTO(
|
842
|
+
sucesso=False,
|
843
|
+
retorno=retorno,
|
844
|
+
status=RpaHistoricoStatusEnum.Falha,
|
845
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
846
|
+
)
|
847
|
+
else:
|
848
|
+
retorno = f"Não foi possivel realizar a confirmação do msg do OCR \nEtapas Executadas:\n{steps}"
|
849
|
+
return RpaRetornoProcessoDTO(
|
850
|
+
sucesso=False,
|
851
|
+
retorno=retorno,
|
852
|
+
status=RpaHistoricoStatusEnum.Falha,
|
853
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
854
|
+
)
|
833
855
|
except Exception as e:
|
834
856
|
pass
|
835
857
|
|
@@ -36,6 +36,7 @@ async def perform_task(task: RpaProcessoEntradaDTO):
|
|
36
36
|
logger.info(log_msg)
|
37
37
|
task_uuid = task.uuidProcesso
|
38
38
|
url_retorno = task.configEntrada.get("urlRetorno", None)
|
39
|
+
identificador_webhook = task.configEntrada.get("identificador", None)
|
39
40
|
processo: RpaProcesso = await get_processo(task_uuid)
|
40
41
|
if processo is None:
|
41
42
|
worker_config = load_worker_config()
|
@@ -77,7 +78,10 @@ async def perform_task(task: RpaProcessoEntradaDTO):
|
|
77
78
|
show_toast("Sucesso", f"Processo executado com sucesso: {result}")
|
78
79
|
|
79
80
|
if url_retorno is not None and result.sucesso == False:
|
80
|
-
|
81
|
+
if identificador_webhook:
|
82
|
+
await send_to_webhook(url_retorno, result.status, result.retorno, identificador_webhook)
|
83
|
+
else:
|
84
|
+
await send_to_webhook(url_retorno, result.status, result.retorno)
|
81
85
|
return result
|
82
86
|
else:
|
83
87
|
err_msg = f"Processo não encontrado: {task_uuid}"
|
@@ -3437,6 +3437,60 @@ async def ocr_warnings(numero_nota: str)-> RpaRetornoProcessoDTO:
|
|
3437
3437
|
pass
|
3438
3438
|
|
3439
3439
|
|
3440
|
+
async def ocr_by_class(numero_nota: str, windows_class: str, app_class: str)-> RpaRetornoProcessoDTO:
|
3441
|
+
try:
|
3442
|
+
app = Application().connect(class_name=windows_class)
|
3443
|
+
main_window = app[app_class]
|
3444
|
+
main_window.set_focus()
|
3445
|
+
|
3446
|
+
console.print(f"Obtendo texto da Janela...\n")
|
3447
|
+
console.print(f"Tirando print da janela do warning para realização do OCR...\n")
|
3448
|
+
|
3449
|
+
window_rect = main_window.rectangle()
|
3450
|
+
screenshot = pyautogui.screenshot(
|
3451
|
+
region=(
|
3452
|
+
window_rect.left,
|
3453
|
+
window_rect.top,
|
3454
|
+
window_rect.width(),
|
3455
|
+
window_rect.height(),
|
3456
|
+
)
|
3457
|
+
)
|
3458
|
+
username = getpass.getuser()
|
3459
|
+
path_to_png = f"C:\\Users\\{username}\\Downloads\\ocr_bt_class_popup_{numero_nota}.png"
|
3460
|
+
screenshot.save(path_to_png)
|
3461
|
+
console.print(f"Print salvo em {path_to_png}...\n")
|
3462
|
+
|
3463
|
+
console.print(
|
3464
|
+
f"Preparando a imagem para maior resolução e assertividade no OCR...\n"
|
3465
|
+
)
|
3466
|
+
image = Image.open(path_to_png)
|
3467
|
+
image = image.convert("L")
|
3468
|
+
enhancer = ImageEnhance.Contrast(image)
|
3469
|
+
image = enhancer.enhance(2.0)
|
3470
|
+
image.save(path_to_png)
|
3471
|
+
console.print(f"Imagem preparada com sucesso...\n")
|
3472
|
+
console.print(f"Realizando OCR...\n")
|
3473
|
+
captured_text = pytesseract.image_to_string(Image.open(path_to_png))
|
3474
|
+
console.print(f"Texto Full capturado {captured_text}...\n")
|
3475
|
+
return RpaRetornoProcessoDTO(
|
3476
|
+
sucesso=True,
|
3477
|
+
retorno=captured_text,
|
3478
|
+
status=RpaHistoricoStatusEnum.Sucesso,
|
3479
|
+
)
|
3480
|
+
except Exception as e:
|
3481
|
+
return RpaRetornoProcessoDTO(
|
3482
|
+
sucesso=False,
|
3483
|
+
retorno=f"Erro ao realizar a extração do texto vinculado ao warning, erro - {e}",
|
3484
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3485
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3486
|
+
)
|
3487
|
+
finally:
|
3488
|
+
try:
|
3489
|
+
os.remove(path_to_png)
|
3490
|
+
except:
|
3491
|
+
pass
|
3492
|
+
|
3493
|
+
|
3440
3494
|
async def nf_busca_nf_saida(num_nota_fiscal: str) -> RpaRetornoProcessoDTO:
|
3441
3495
|
try:
|
3442
3496
|
app = Application().connect(class_name="TFrmNotaFiscalSaida", timeout=60)
|
@@ -3592,30 +3646,54 @@ async def nf_devolucao_liquidar_cupom(num_nota_fiscal: str, data_atual: str) ->
|
|
3592
3646
|
await worker_sleep(3)
|
3593
3647
|
confirm_pop_up = await is_window_open_by_class("TMessageForm","TMessageForm")
|
3594
3648
|
if confirm_pop_up["IsOpened"] == True:
|
3595
|
-
|
3596
|
-
|
3597
|
-
|
3598
|
-
|
3599
|
-
|
3600
|
-
|
3601
|
-
|
3602
|
-
|
3603
|
-
|
3604
|
-
|
3605
|
-
|
3606
|
-
|
3607
|
-
|
3608
|
-
|
3609
|
-
|
3610
|
-
|
3649
|
+
capture_text_ocr = await ocr_by_class(num_nota_fiscal,"TMessageForm","TMessageForm")
|
3650
|
+
if capture_text_ocr.sucesso == True:
|
3651
|
+
msg_result = capture_text_ocr.retorno
|
3652
|
+
if "deseja realmente" in msg_result.lower():
|
3653
|
+
app_confirm = Application().connect(class_name="TMessageForm")
|
3654
|
+
main_window_confirm = app_confirm["TMessageForm"]
|
3655
|
+
|
3656
|
+
btn_yes = main_window_confirm["&Yes"]
|
3657
|
+
try:
|
3658
|
+
btn_yes.click()
|
3659
|
+
await worker_sleep(3)
|
3660
|
+
console.print("O botão Yes foi clicado com sucesso.", style="green")
|
3661
|
+
#main_window.close()
|
3662
|
+
except:
|
3663
|
+
return RpaRetornoProcessoDTO(
|
3664
|
+
sucesso=False,
|
3665
|
+
retorno=f"Não foi possivel clicar em Yes durante para a confirmação da liquidação do titulo",
|
3666
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3667
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3668
|
+
)
|
3669
|
+
else:
|
3670
|
+
return RpaRetornoProcessoDTO(
|
3671
|
+
sucesso=False,
|
3672
|
+
retorno=f"POP não mapeado: {msg_result}",
|
3673
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3674
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3675
|
+
)
|
3611
3676
|
|
3612
3677
|
console.print('Aguardando a confirmação de Liquidação realizado com sucesso')
|
3613
3678
|
try:
|
3614
3679
|
app = Application().connect(title="Informação", timeout=60)
|
3615
3680
|
main_window = app["Informação"]
|
3616
3681
|
main_window.set_focus()
|
3617
|
-
|
3618
|
-
|
3682
|
+
msg_pop_up = await ocr_by_class(num_nota_fiscal,"TMessageForm","TMessageForm")
|
3683
|
+
if msg_pop_up.sucesso == True:
|
3684
|
+
msg_result = msg_pop_up.retorno
|
3685
|
+
if "sucesso" in msg_result.lower():
|
3686
|
+
btn_ok = main_window.child_window(class_name="Button")
|
3687
|
+
btn_ok.click()
|
3688
|
+
pyautogui.press('enter')
|
3689
|
+
await worker_sleep(1)
|
3690
|
+
else:
|
3691
|
+
return RpaRetornoProcessoDTO(
|
3692
|
+
sucesso=False,
|
3693
|
+
retorno=f"Não foi possivel obter a confirmação de titulo liquidado com sucesso, pop_up nao mepeado: {msg_result}",
|
3694
|
+
status=RpaHistoricoStatusEnum.Falha,
|
3695
|
+
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3696
|
+
)
|
3619
3697
|
except Exception as e:
|
3620
3698
|
return RpaRetornoProcessoDTO(
|
3621
3699
|
sucesso=False,
|
@@ -3624,6 +3702,10 @@ async def nf_devolucao_liquidar_cupom(num_nota_fiscal: str, data_atual: str) ->
|
|
3624
3702
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)]
|
3625
3703
|
)
|
3626
3704
|
|
3705
|
+
|
3706
|
+
app = Application().connect(class_name="TFrmTituloReceber", timeout=60)
|
3707
|
+
main_window = app["TFrmTituloReceber"]
|
3708
|
+
main_window.set_focus()
|
3627
3709
|
console.print('Confirmando se o titulo alterou para Liquidado')
|
3628
3710
|
panel_TPage = main_window.child_window(class_name="TcxTreeView")
|
3629
3711
|
panel_TTabSheet = panel_TPage.child_window(class_name="TcxCustomInnerTreeView")
|
@@ -3638,6 +3720,9 @@ async def nf_devolucao_liquidar_cupom(num_nota_fiscal: str, data_atual: str) ->
|
|
3638
3720
|
|
3639
3721
|
if radio_liquidado.is_checked():
|
3640
3722
|
console.print("Botão 'Liquidado' está selecionado, seguindo com o processo...\n")
|
3723
|
+
app = Application().connect(class_name="TFrmTituloReceber", timeout=60)
|
3724
|
+
main_window = app["TFrmTituloReceber"]
|
3725
|
+
main_window.set_focus()
|
3641
3726
|
main_window.close()
|
3642
3727
|
else:
|
3643
3728
|
return RpaRetornoProcessoDTO(
|
@@ -7,7 +7,7 @@ worker_automate_hub/api/helpers/api_helpers.py,sha256=SkheO2fXexeh-a4shr8Qzsz_kZ
|
|
7
7
|
worker_automate_hub/api/rdp_service.py,sha256=L7orr60FkJr6zjETtA4me8tRYCW9m1g-i5pq6AILUFo,1647
|
8
8
|
worker_automate_hub/api/rpa_fila_service.py,sha256=qa9JLuX6kL9Bv_PyPE_CzIikKwy0WdOf2FrIpFdMcYI,2125
|
9
9
|
worker_automate_hub/api/rpa_historico_service.py,sha256=wQw8_k8i0S-r7qrrn4BSoztkgtiuH_bHRSEytbZebDg,9690
|
10
|
-
worker_automate_hub/api/webhook_service.py,sha256=
|
10
|
+
worker_automate_hub/api/webhook_service.py,sha256=S1a8IIS5LYY16I5E2pPPczaUnUz-_CwmD9_1QBdQD2g,1879
|
11
11
|
worker_automate_hub/cli.py,sha256=JB45pjPJ8_E-4xw0OjqDMcAw-tpDV0mjmvwJRTnTzY0,6862
|
12
12
|
worker_automate_hub/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
13
|
worker_automate_hub/config/settings.py,sha256=4BkIYV0C9C_tl68WNfw3aoywr1-_bRJsKysSnSRALT0,2450
|
@@ -37,7 +37,7 @@ worker_automate_hub/tasks/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
|
|
37
37
|
worker_automate_hub/tasks/jobs/coleta_dje_process.py,sha256=UkLWTC5Ub2qBb0yY-8IZ0DLLOVJOfNTq_z9krx_t25Q,29476
|
38
38
|
worker_automate_hub/tasks/jobs/conexao_rdp.py,sha256=lNjD-JxpPTXdvFEJAkajC_Ltyw81rIEJeu7FUfRf2qI,9586
|
39
39
|
worker_automate_hub/tasks/jobs/descartes.py,sha256=0bMCJ0xIcK8TLSgjF6taAbGFLMU-sGDVFIhUYSRtrbg,41092
|
40
|
-
worker_automate_hub/tasks/jobs/devolucao_prazo_a_faturar.py,sha256=
|
40
|
+
worker_automate_hub/tasks/jobs/devolucao_prazo_a_faturar.py,sha256=PErDGphh75kc5SGJKI90L26qPJKl0BAkk8eRgjwmRvA,79240
|
41
41
|
worker_automate_hub/tasks/jobs/ecac_estadual_go.py,sha256=dKkf22nH5gp3RErq5u0UzRsKyJ81fc6ZZ4vLtUuMwHA,21002
|
42
42
|
worker_automate_hub/tasks/jobs/ecac_estadual_main.py,sha256=8WmKe4-MRtzHobXz2S4YBDNN8alfawkC-BBlRY-mn1g,1726
|
43
43
|
worker_automate_hub/tasks/jobs/ecac_estadual_mt.py,sha256=C26zmpGQGUq6sP9lU9nanM3Fje-rkyx5tjwmRy4lyL8,25300
|
@@ -66,17 +66,17 @@ worker_automate_hub/tasks/jobs/playground.py,sha256=7vWDg9DwToHwGJ6_XOa8TQ6LmfRV
|
|
66
66
|
worker_automate_hub/tasks/jobs/sped_fiscal.py,sha256=uHA5zQmAqqb-L_jdbBKiqINV4vXI58CL3wAI-2Xt_oQ,28938
|
67
67
|
worker_automate_hub/tasks/jobs/transferencias.py,sha256=i3fCanHZ_pSwPW03THpQPqlzrDjbV4QbKkXpUqV3dxM,39272
|
68
68
|
worker_automate_hub/tasks/task_definitions.py,sha256=yNu2GSC1PxjblcMgT7UOFhEUq4CMaQqDfN3hAF4yz_U,4954
|
69
|
-
worker_automate_hub/tasks/task_executor.py,sha256=
|
69
|
+
worker_automate_hub/tasks/task_executor.py,sha256=1ZBVW2QS0io-gVyR4VNnbpaLJnSpTxtHIbRlnuQuj1Y,5566
|
70
70
|
worker_automate_hub/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
71
71
|
worker_automate_hub/utils/env.py,sha256=TacQjGRO7PUNpttrhTAc5Gnegaiysl2Knsv1P8qfkfs,57
|
72
72
|
worker_automate_hub/utils/get_creds_gworkspace.py,sha256=ZJ0IIEjM4IXIV9rwfbOZ1V1wiaMoJAGZeSy0D37sYdU,2212
|
73
73
|
worker_automate_hub/utils/logger.py,sha256=FYV9fg0_RAYJF_ZOCJEbqQAiCXlXk2gMpvUU1rzT_xs,671
|
74
74
|
worker_automate_hub/utils/toast.py,sha256=xPHc5r5uOxB_cZlCzm13Kt2qSKLLFZALncU6Qg3Ft68,1162
|
75
75
|
worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbVlwDl49Y,7972
|
76
|
-
worker_automate_hub/utils/util.py,sha256=
|
76
|
+
worker_automate_hub/utils/util.py,sha256=ch8qDZfKBHCYKKjblVSQ4X07m9AsYpOPD5RflaipDm0,159514
|
77
77
|
worker_automate_hub/utils/utils_nfe_entrada.py,sha256=iYpOs7fb7C3bY61QHySr00xlDNzrrCP0zaexOpBPuaQ,31930
|
78
78
|
worker_automate_hub/worker.py,sha256=CT-poyP1ZYvubArYsnnNd9oJ53SPaDwgr6p6keS3nI4,6248
|
79
|
-
worker_automate_hub-0.5.
|
80
|
-
worker_automate_hub-0.5.
|
81
|
-
worker_automate_hub-0.5.
|
82
|
-
worker_automate_hub-0.5.
|
79
|
+
worker_automate_hub-0.5.54.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
80
|
+
worker_automate_hub-0.5.54.dist-info/METADATA,sha256=MpWKhIzCV_6rKtJD-Vfn7LYwGeqXpIfixLPCPDN-vjo,2894
|
81
|
+
worker_automate_hub-0.5.54.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
|
82
|
+
worker_automate_hub-0.5.54.dist-info/RECORD,,
|
File without changes
|
{worker_automate_hub-0.5.53.dist-info → worker_automate_hub-0.5.54.dist-info}/entry_points.txt
RENAMED
File without changes
|