worker-automate-hub 0.5.760__py3-none-any.whl → 0.5.761__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/extracao_saldo_estoque_fiscal.py +152 -87
- {worker_automate_hub-0.5.760.dist-info → worker_automate_hub-0.5.761.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.760.dist-info → worker_automate_hub-0.5.761.dist-info}/RECORD +5 -5
- {worker_automate_hub-0.5.760.dist-info → worker_automate_hub-0.5.761.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.760.dist-info → worker_automate_hub-0.5.761.dist-info}/entry_points.txt +0 -0
@@ -282,105 +282,169 @@ async def extracao_saldo_estoque_fiscal(
|
|
282
282
|
|
283
283
|
await worker_sleep(2)
|
284
284
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
if
|
296
|
-
pyautogui.
|
297
|
-
|
285
|
+
max_tentativas = 5
|
286
|
+
tentativa = 1
|
287
|
+
sucesso = False
|
288
|
+
|
289
|
+
while tentativa <= max_tentativas and not sucesso:
|
290
|
+
console.print(f"Tentativa {tentativa} de {max_tentativas}", style="bold cyan")
|
291
|
+
|
292
|
+
# 1) Abrir o picker de formatos pelo botão (imagem)
|
293
|
+
console.print("Procurando botão de salvar (imagem)...", style="bold cyan")
|
294
|
+
caminho_img = r'assets\\extracao_relatorios\\btn_salvar.png'
|
295
|
+
if os.path.isfile(caminho_img):
|
296
|
+
pos = pyautogui.locateCenterOnScreen(caminho_img, confidence=0.9)
|
297
|
+
if pos:
|
298
|
+
pyautogui.click(pos)
|
299
|
+
console.print("Clique realizado no botão salvar", style="bold green")
|
300
|
+
else:
|
301
|
+
console.print("Imagem encontrada mas não está visível na tela", style="bold yellow")
|
298
302
|
else:
|
299
|
-
print("Imagem
|
300
|
-
else:
|
301
|
-
print("A imagem NÃO existe:", caminho)
|
302
|
-
|
303
|
-
await worker_sleep(2)
|
304
|
-
|
305
|
-
# Conecta na janela Configuração para Salvar Arquivo
|
306
|
-
app = Application().connect(class_name="TFrmRelatorioFormato", found_index=0)
|
307
|
-
main_window = app["TFrmRelatorioFormato"]
|
308
|
-
main_window.set_focus()
|
309
|
-
# Acessa o ComboBox pelo identificador conhecido
|
310
|
-
combo = main_window.ComboBox
|
303
|
+
console.print("Imagem do botão salvar NÃO existe", style="bold red")
|
311
304
|
|
312
|
-
|
313
|
-
itens = combo.texts()
|
314
|
-
print("Itens do ComboBox:", itens)
|
315
|
-
|
316
|
-
# Seleciona o Excel correto (o segundo da lista, índice 8)
|
317
|
-
combo.select(8)
|
318
|
-
|
319
|
-
await worker_sleep(2)
|
320
|
-
|
321
|
-
# Clicar em Salvar
|
322
|
-
btn_salvar = main_window.child_window(
|
323
|
-
class_name="TBitBtn", found_index=1
|
324
|
-
).click_input()
|
305
|
+
await worker_sleep(8)
|
325
306
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
307
|
+
# 2) Selecionar formato "Excel" na janela TFrmRelatorioFormato
|
308
|
+
console.print("Selecionando formato Excel...", style="bold cyan")
|
309
|
+
try:
|
310
|
+
app_fmt = Application().connect(class_name="TFrmRelatorioFormato", timeout=10)
|
311
|
+
win_fmt = app_fmt["TFrmRelatorioFormato"]
|
312
|
+
win_fmt.wait("visible", timeout=10)
|
313
|
+
|
314
|
+
combo = win_fmt.ComboBox
|
315
|
+
textos = combo.texts()
|
316
|
+
console.print(f"Itens do ComboBox: {textos}", style="bold yellow")
|
317
|
+
|
318
|
+
# Se souber o índice correto, mantenha. Caso contrário, tente por texto contendo 'Excel'
|
319
|
+
try:
|
320
|
+
combo.select(8)
|
321
|
+
except Exception:
|
322
|
+
alvo = None
|
323
|
+
for i, t in enumerate(textos):
|
324
|
+
if "EXCEL" in str(t).upper() or "XLSX" in str(t).upper():
|
325
|
+
alvo = i
|
326
|
+
break
|
327
|
+
if alvo is not None:
|
328
|
+
combo.select(alvo)
|
329
|
+
else:
|
330
|
+
console.print("Não foi possível localizar a opção de Excel no ComboBox.", style="bold red")
|
331
|
+
tentativa += 1
|
332
|
+
await worker_sleep(2)
|
333
|
+
continue
|
334
|
+
|
335
|
+
await worker_sleep(1)
|
336
|
+
|
337
|
+
# Botão OK/Confirmar na janela de formato
|
338
|
+
win_fmt.child_window(class_name="TBitBtn", found_index=1).wait("enabled", timeout=5)
|
339
|
+
win_fmt.child_window(class_name="TBitBtn", found_index=1).click_input()
|
340
|
+
except Exception as e:
|
341
|
+
console.print(f"Falha ao selecionar formato: {e}", style="bold red")
|
342
|
+
tentativa += 1
|
343
|
+
await worker_sleep(3)
|
344
|
+
continue
|
360
345
|
|
361
|
-
|
346
|
+
await worker_sleep(5)
|
362
347
|
|
363
|
-
|
348
|
+
# 3) Janela "Salvar para arquivo"
|
349
|
+
console.print("Abrindo janela de salvar arquivo...", style="bold cyan")
|
350
|
+
try:
|
351
|
+
app_save = Application().connect(title_re="Salvar para arquivo", timeout=30)
|
352
|
+
win_save = app_save.window(title_re="Salvar para arquivo")
|
353
|
+
win_save.wait("visible", timeout=30)
|
354
|
+
except Exception as e:
|
355
|
+
console.print(f"Não achou a janela 'Salvar para arquivo': {e}", style="bold red")
|
356
|
+
tentativa += 1
|
357
|
+
await worker_sleep(3)
|
358
|
+
continue
|
359
|
+
|
360
|
+
# Caminho do arquivo a salvar
|
361
|
+
caminho_arquivo = rf"C:\Users\automatehub\Downloads\saldo_estoque_fiscal_{periodo_format}_{filial}.xlsx"
|
362
|
+
|
363
|
+
# Se já existe, removemos para evitar pop-up de confirmação
|
364
|
+
if os.path.exists(caminho_arquivo):
|
365
|
+
try:
|
366
|
+
os.remove(caminho_arquivo)
|
367
|
+
console.print("Arquivo existente removido para evitar prompt de sobrescrita.", style="bold yellow")
|
368
|
+
except Exception as e:
|
369
|
+
console.print(f"Não foi possível remover o arquivo existente: {e}", style="bold red")
|
364
370
|
|
365
|
-
|
366
|
-
|
371
|
+
try:
|
372
|
+
# Campo "Nome" (Edit, control_id=1148)
|
373
|
+
campo_nome = win_save.child_window(class_name="Edit", control_id=1148).wrapper_object()
|
374
|
+
campo_nome.set_focus()
|
375
|
+
# limpa conteúdo
|
376
|
+
try:
|
377
|
+
campo_nome.set_edit_text("")
|
378
|
+
except Exception:
|
379
|
+
# fallback limpando com Ctrl+A + Delete
|
380
|
+
campo_nome.type_keys("^a{DELETE}", pause=0.02)
|
381
|
+
|
382
|
+
# digita caminho
|
383
|
+
campo_nome.type_keys(caminho_arquivo, with_spaces=True, pause=0.01)
|
384
|
+
console.print(f"Arquivo configurado para: {caminho_arquivo}", style="bold green")
|
385
|
+
|
386
|
+
await worker_sleep(1)
|
387
|
+
|
388
|
+
# Botão Salvar (primeiro Button)
|
389
|
+
btn_salvar = win_save.child_window(class_name="Button", found_index=0)
|
390
|
+
btn_salvar.wait("enabled", timeout=10)
|
391
|
+
btn_salvar.click_input()
|
392
|
+
except Exception as e:
|
393
|
+
console.print(f"Erro ao confirmar salvar: {e}", style="bold red")
|
394
|
+
tentativa += 1
|
395
|
+
await worker_sleep(3)
|
396
|
+
continue
|
367
397
|
|
368
|
-
|
398
|
+
await worker_sleep(2)
|
369
399
|
|
370
|
-
|
400
|
+
# 3.1) Tratar confirmação de sobrescrita, se aparecer
|
401
|
+
try:
|
402
|
+
# Pode vir em PT/EN dependendo do SO
|
403
|
+
# Título comum: "Confirm Save As" (EN) ou "Confirmar Salvar Como" (PT)
|
404
|
+
try:
|
405
|
+
app_conf = Application().connect(title_re="Confirm(ar)?( )?Salvar( )?Como|Confirm Save As", timeout=3)
|
406
|
+
win_conf = app_conf.window(title_re="Confirm(ar)?( )?Salvar( )?Como|Confirm Save As")
|
407
|
+
win_conf.wait("visible", timeout=3)
|
408
|
+
# Botões costumam ser "Sim"/"Yes" como class_name="Button"
|
409
|
+
# Tente o primeiro botão (Yes/Sim)
|
410
|
+
win_conf.child_window(class_name="Button", found_index=0).click_input()
|
411
|
+
console.print("Confirmação de sobrescrita respondida.", style="bold yellow")
|
412
|
+
except Exception:
|
413
|
+
pass
|
414
|
+
except Exception:
|
415
|
+
pass
|
371
416
|
|
372
|
-
|
417
|
+
await worker_sleep(2)
|
373
418
|
|
374
|
-
|
375
|
-
|
376
|
-
|
419
|
+
# 4) Aguardar o processamento/Printing encerrar
|
420
|
+
console.print("Aguardando finalização do processo de impressão/salvamento...", style="bold cyan")
|
421
|
+
try:
|
422
|
+
app_print = Application().connect(title_re="Printing", timeout=5)
|
423
|
+
win_print = app_print.window(title_re="Printing")
|
424
|
+
try:
|
425
|
+
win_print.wait_not("visible", timeout=60)
|
426
|
+
console.print("Janela 'Printing' fechada.", style="bold green")
|
427
|
+
except Exception:
|
428
|
+
console.print("Janela 'Printing' não fechou no tempo esperado. Seguindo.", style="bold yellow")
|
429
|
+
except findwindows.ElementNotFoundError:
|
430
|
+
console.print("Janela 'Printing' não apareceu.", style="bold yellow")
|
431
|
+
except Exception as e:
|
432
|
+
console.print(f"Erro ao aguardar 'Printing': {e}", style="bold yellow")
|
433
|
+
|
434
|
+
# 5) Validar arquivo salvo
|
435
|
+
if os.path.exists(caminho_arquivo):
|
436
|
+
console.print(f"Arquivo encontrado: {caminho_arquivo}", style="bold green")
|
437
|
+
with open(caminho_arquivo, "rb") as f:
|
438
|
+
file_bytes = io.BytesIO(f.read())
|
439
|
+
sucesso = True
|
440
|
+
else:
|
441
|
+
console.print("Arquivo não encontrado, tentando novamente...", style="bold red")
|
442
|
+
tentativa += 1
|
443
|
+
await worker_sleep(3)
|
377
444
|
|
378
|
-
|
379
|
-
|
380
|
-
print("✅ Janela 'Printing' fechada.")
|
445
|
+
if not sucesso:
|
446
|
+
console.print("Falha após 5 tentativas. Arquivo não foi gerado.", style="bold red")
|
381
447
|
|
382
|
-
except findwindows.ElementNotFoundError:
|
383
|
-
print("⚠️ Janela 'Printing' não estava aberta.")
|
384
448
|
|
385
449
|
nome_com_extensao = f"saldo_estoque_fiscal_{periodo_format}_{filial}.xlsx"
|
386
450
|
# lê o arquivo
|
@@ -424,3 +488,4 @@ async def extracao_saldo_estoque_fiscal(
|
|
424
488
|
status=RpaHistoricoStatusEnum.Falha,
|
425
489
|
tags=[RpaTagDTO(descricao=RpaTagEnum.Tecnico)],
|
426
490
|
)
|
491
|
+
|
@@ -71,7 +71,7 @@ worker_automate_hub/tasks/jobs/exemplo_processo.py,sha256=nV0iLoip2FH2-FhLmhX3nP
|
|
71
71
|
worker_automate_hub/tasks/jobs/extracao_fechamento_contabil.py,sha256=6Kr5DKjKLqtFvGzyiXtt7xrQsuU898l8pQXDq9C6AX8,19567
|
72
72
|
worker_automate_hub/tasks/jobs/extracao_fechamento_emsys.py,sha256=-T2nZUDiFrUGm_KLxJd_4qcrageDxVpWW3KAAniLFC4,21448
|
73
73
|
worker_automate_hub/tasks/jobs/extracao_saldo_estoque.py,sha256=nFAv5Bvwwo2Mhy69q5BqR-XsKtg4KIqAunrUmGeW1S0,9173
|
74
|
-
worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py,sha256=
|
74
|
+
worker_automate_hub/tasks/jobs/extracao_saldo_estoque_fiscal.py,sha256=d4ckXWJ2sZmE8femwVsGpy6YRIqcleEUOyhLDpjoidM,20010
|
75
75
|
worker_automate_hub/tasks/jobs/fechar_conexao_rdp.py,sha256=UWAKCS2dbfgDlSQOBdjmVJXfD1MMuUrOi3weDgB0CAc,5718
|
76
76
|
worker_automate_hub/tasks/jobs/fidc_exportacao_docs_portal_b2b.py,sha256=tWUmYy3Zhi3JEt8AoqTsWpU-wbf5-OxhCrTOooh1WH4,15616
|
77
77
|
worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py,sha256=FAmcCqKVjedf7wIped8XRLIZ9S3oWc6fakF-r1Zm0kg,12637
|
@@ -101,7 +101,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
|
|
101
101
|
worker_automate_hub/utils/util.py,sha256=V2WtWoETdTrAtGA8UgeqAAVphUj9KkGSZFzYsHJFATA,210055
|
102
102
|
worker_automate_hub/utils/utils_nfe_entrada.py,sha256=TOXKSHOPxy8N3-ROpTGjNIHstX0i2b8qekcj1tRvjG8,38174
|
103
103
|
worker_automate_hub/worker.py,sha256=uhZ3f-iaQ1i8cANbljp50vkYl-Xm0_sHtjwwF_2y72o,7191
|
104
|
-
worker_automate_hub-0.5.
|
105
|
-
worker_automate_hub-0.5.
|
106
|
-
worker_automate_hub-0.5.
|
107
|
-
worker_automate_hub-0.5.
|
104
|
+
worker_automate_hub-0.5.761.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
105
|
+
worker_automate_hub-0.5.761.dist-info/METADATA,sha256=QkyzB7A1SY7-XUnJpdV0SyGi78QauZQ6N1-rjyb2T_U,3049
|
106
|
+
worker_automate_hub-0.5.761.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
107
|
+
worker_automate_hub-0.5.761.dist-info/RECORD,,
|
File without changes
|
{worker_automate_hub-0.5.760.dist-info → worker_automate_hub-0.5.761.dist-info}/entry_points.txt
RENAMED
File without changes
|