worker-automate-hub 0.5.761__py3-none-any.whl → 0.5.762__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.py +119 -28
- {worker_automate_hub-0.5.761.dist-info → worker_automate_hub-0.5.762.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.761.dist-info → worker_automate_hub-0.5.762.dist-info}/RECORD +5 -5
- {worker_automate_hub-0.5.761.dist-info → worker_automate_hub-0.5.762.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.761.dist-info → worker_automate_hub-0.5.762.dist-info}/entry_points.txt +0 -0
@@ -117,10 +117,11 @@ async def extracao_saldo_estoque(task: RpaProcessoEntradaDTO):
|
|
117
117
|
while tentativa <= max_tentativas and not sucesso:
|
118
118
|
console.print(f"Tentativa {tentativa} de {max_tentativas}", style="bold cyan")
|
119
119
|
|
120
|
+
# 1) Abrir o picker de formatos pelo botão (imagem)
|
120
121
|
console.print("Procurando botão de salvar (imagem)...", style="bold cyan")
|
121
|
-
|
122
|
-
if os.path.isfile(
|
123
|
-
pos = pyautogui.locateCenterOnScreen(
|
122
|
+
caminho_img = r'assets\\extracao_relatorios\\btn_salvar.png'
|
123
|
+
if os.path.isfile(caminho_img):
|
124
|
+
pos = pyautogui.locateCenterOnScreen(caminho_img, confidence=0.9)
|
124
125
|
if pos:
|
125
126
|
pyautogui.click(pos)
|
126
127
|
console.print("Clique realizado no botão salvar", style="bold green")
|
@@ -131,49 +132,139 @@ async def extracao_saldo_estoque(task: RpaProcessoEntradaDTO):
|
|
131
132
|
|
132
133
|
await worker_sleep(8)
|
133
134
|
|
135
|
+
# 2) Selecionar formato "Excel" na janela TFrmRelatorioFormato
|
134
136
|
console.print("Selecionando formato Excel...", style="bold cyan")
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
137
|
+
try:
|
138
|
+
app_fmt = Application().connect(class_name="TFrmRelatorioFormato", timeout=10)
|
139
|
+
win_fmt = app_fmt["TFrmRelatorioFormato"]
|
140
|
+
win_fmt.wait("visible", timeout=10)
|
141
|
+
|
142
|
+
combo = win_fmt.ComboBox
|
143
|
+
textos = combo.texts()
|
144
|
+
console.print(f"Itens do ComboBox: {textos}", style="bold yellow")
|
145
|
+
|
146
|
+
# Se souber o índice correto, mantenha. Caso contrário, tente por texto contendo 'Excel'
|
147
|
+
try:
|
148
|
+
combo.select(8)
|
149
|
+
except Exception:
|
150
|
+
alvo = None
|
151
|
+
for i, t in enumerate(textos):
|
152
|
+
if "EXCEL" in str(t).upper() or "XLSX" in str(t).upper():
|
153
|
+
alvo = i
|
154
|
+
break
|
155
|
+
if alvo is not None:
|
156
|
+
combo.select(alvo)
|
157
|
+
else:
|
158
|
+
console.print("Não foi possível localizar a opção de Excel no ComboBox.", style="bold red")
|
159
|
+
tentativa += 1
|
160
|
+
await worker_sleep(2)
|
161
|
+
continue
|
162
|
+
|
163
|
+
await worker_sleep(1)
|
164
|
+
|
165
|
+
# Botão OK/Confirmar na janela de formato
|
166
|
+
# Em muitos Delphi VCL, TBitBtn com found_index=1 costuma ser OK.
|
167
|
+
win_fmt.child_window(class_name="TBitBtn", found_index=1).wait("enabled", timeout=5)
|
168
|
+
win_fmt.child_window(class_name="TBitBtn", found_index=1).click_input()
|
169
|
+
except Exception as e:
|
170
|
+
console.print(f"Falha ao selecionar formato: {e}", style="bold red")
|
171
|
+
tentativa += 1
|
172
|
+
await worker_sleep(3)
|
173
|
+
continue
|
145
174
|
|
146
175
|
await worker_sleep(5)
|
147
176
|
|
177
|
+
# 3) Janela "Salvar para arquivo"
|
148
178
|
console.print("Abrindo janela de salvar arquivo...", style="bold cyan")
|
149
|
-
|
150
|
-
|
179
|
+
try:
|
180
|
+
app_save = Application().connect(title_re="Salvar para arquivo", timeout=30)
|
181
|
+
win_save = app_save.window(title_re="Salvar para arquivo")
|
182
|
+
win_save.wait("visible", timeout=30)
|
183
|
+
except Exception as e:
|
184
|
+
console.print(f"Não achou a janela 'Salvar para arquivo': {e}", style="bold red")
|
185
|
+
tentativa += 1
|
186
|
+
await worker_sleep(3)
|
187
|
+
continue
|
151
188
|
|
189
|
+
# Caminho do arquivo a salvar
|
152
190
|
caminho_arquivo = rf"C:\Users\automatehub\Downloads\saldo_estoque_{periodo_format}_{filial}.xlsx"
|
153
|
-
|
154
|
-
|
155
|
-
|
191
|
+
|
192
|
+
# Se já existe, removemos para evitar pop-up de confirmação
|
193
|
+
if os.path.exists(caminho_arquivo):
|
194
|
+
try:
|
195
|
+
os.remove(caminho_arquivo)
|
196
|
+
console.print("Arquivo existente removido para evitar prompt de sobrescrita.", style="bold yellow")
|
197
|
+
except Exception as e:
|
198
|
+
console.print(f"Não foi possível remover o arquivo existente: {e}", style="bold red")
|
199
|
+
|
200
|
+
try:
|
201
|
+
# Campo "Nome" (Edit, control_id=1148)
|
202
|
+
campo_nome = win_save.child_window(class_name="Edit", control_id=1148).wrapper_object()
|
203
|
+
campo_nome.set_focus()
|
204
|
+
# limpa conteúdo
|
205
|
+
try:
|
206
|
+
campo_nome.set_edit_text("")
|
207
|
+
except Exception:
|
208
|
+
# fallback limpando com Ctrl+A + Delete
|
209
|
+
campo_nome.type_keys("^a{DELETE}", pause=0.02)
|
210
|
+
|
211
|
+
# digita caminho
|
212
|
+
campo_nome.type_keys(caminho_arquivo, with_spaces=True, pause=0.01)
|
213
|
+
console.print(f"Arquivo configurado para: {caminho_arquivo}", style="bold green")
|
214
|
+
|
215
|
+
await worker_sleep(1)
|
216
|
+
|
217
|
+
# Botão Salvar (primeiro Button)
|
218
|
+
btn_salvar = win_save.child_window(class_name="Button", found_index=0)
|
219
|
+
btn_salvar.wait("enabled", timeout=10)
|
220
|
+
btn_salvar.click_input()
|
221
|
+
except Exception as e:
|
222
|
+
console.print(f"Erro ao confirmar salvar: {e}", style="bold red")
|
223
|
+
tentativa += 1
|
224
|
+
await worker_sleep(3)
|
225
|
+
continue
|
156
226
|
|
157
227
|
await worker_sleep(2)
|
158
|
-
|
159
|
-
main_window.child_window(class_name="Button", found_index=0).click_input()
|
160
228
|
|
161
|
-
|
229
|
+
# 3.1) Tratar confirmação de sobrescrita, se aparecer
|
230
|
+
try:
|
231
|
+
# Pode vir em PT/EN dependendo do SO
|
232
|
+
# Título comum: "Confirm Save As" (EN) ou "Confirmar Salvar Como" (PT)
|
233
|
+
try:
|
234
|
+
app_conf = Application().connect(title_re="Confirm(ar)?( )?Salvar( )?Como|Confirm Save As", timeout=3)
|
235
|
+
win_conf = app_conf.window(title_re="Confirm(ar)?( )?Salvar( )?Como|Confirm Save As")
|
236
|
+
win_conf.wait("visible", timeout=3)
|
237
|
+
# Botões costumam ser "Sim"/"Yes" como class_name="Button"
|
238
|
+
# Tente o primeiro botão (Yes/Sim)
|
239
|
+
win_conf.child_window(class_name="Button", found_index=0).click_input()
|
240
|
+
console.print("Confirmação de sobrescrita respondida.", style="bold yellow")
|
241
|
+
except Exception:
|
242
|
+
pass
|
243
|
+
except Exception:
|
244
|
+
pass
|
245
|
+
|
246
|
+
await worker_sleep(2)
|
162
247
|
|
248
|
+
# 4) Aguardar o processamento/Printing encerrar
|
163
249
|
console.print("Aguardando finalização do processo de impressão/salvamento...", style="bold cyan")
|
164
250
|
try:
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
251
|
+
app_print = Application().connect(title_re="Printing", timeout=5)
|
252
|
+
win_print = app_print.window(title_re="Printing")
|
253
|
+
try:
|
254
|
+
win_print.wait_not("visible", timeout=60)
|
255
|
+
console.print("Janela 'Printing' fechada.", style="bold green")
|
256
|
+
except Exception:
|
257
|
+
console.print("Janela 'Printing' não fechou no tempo esperado. Seguindo.", style="bold yellow")
|
169
258
|
except findwindows.ElementNotFoundError:
|
170
259
|
console.print("Janela 'Printing' não apareceu.", style="bold yellow")
|
260
|
+
except Exception as e:
|
261
|
+
console.print(f"Erro ao aguardar 'Printing': {e}", style="bold yellow")
|
171
262
|
|
172
|
-
#
|
263
|
+
# 5) Validar arquivo salvo
|
173
264
|
if os.path.exists(caminho_arquivo):
|
174
265
|
console.print(f"Arquivo encontrado: {caminho_arquivo}", style="bold green")
|
175
|
-
with open(caminho_arquivo, "rb") as
|
176
|
-
file_bytes = io.BytesIO(
|
266
|
+
with open(caminho_arquivo, "rb") as f:
|
267
|
+
file_bytes = io.BytesIO(f.read())
|
177
268
|
sucesso = True
|
178
269
|
else:
|
179
270
|
console.print("Arquivo não encontrado, tentando novamente...", style="bold red")
|
@@ -70,7 +70,7 @@ worker_automate_hub/tasks/jobs/entrada_de_notas_9000.py,sha256=0mOmS28tQKF5m7vMz
|
|
70
70
|
worker_automate_hub/tasks/jobs/exemplo_processo.py,sha256=nV0iLoip2FH2-FhLmhX3nPqsfl_MPufZ3E5Q5krJvdc,3544
|
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
|
-
worker_automate_hub/tasks/jobs/extracao_saldo_estoque.py,sha256=
|
73
|
+
worker_automate_hub/tasks/jobs/extracao_saldo_estoque.py,sha256=_tmKYCKqd05xueln-nfd3yVhwpkpsflNQY1BDtyzEZQ,13726
|
74
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
|
@@ -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.762.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
105
|
+
worker_automate_hub-0.5.762.dist-info/METADATA,sha256=BEbaURlGZPVFULs8hLkai5d3PzlMyahZkrGyc-YfmyI,3049
|
106
|
+
worker_automate_hub-0.5.762.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
107
|
+
worker_automate_hub-0.5.762.dist-info/RECORD,,
|
File without changes
|
{worker_automate_hub-0.5.761.dist-info → worker_automate_hub-0.5.762.dist-info}/entry_points.txt
RENAMED
File without changes
|