worker-automate-hub 0.5.37__py3-none-any.whl → 0.5.38__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ import asyncio
1
2
  import os
2
3
  from pathlib import Path
3
4
  import getpass
@@ -5,6 +6,7 @@ import aiohttp
5
6
  from worker_automate_hub.config.settings import load_env_config
6
7
  from worker_automate_hub.utils.logger import logger
7
8
 
9
+
8
10
  async def get_xml(chave_acesso: str):
9
11
  env_config, _ = load_env_config()
10
12
  try:
@@ -31,26 +33,33 @@ async def get_xml(chave_acesso: str):
31
33
  logger.error(err_msg)
32
34
  return None
33
35
 
36
+
34
37
  async def save_xml_to_downloads(chave_acesso: str):
35
- xml_content = await get_xml(chave_acesso)
36
- if xml_content:
37
- try:
38
- downloads_path = Path.home() / "Downloads"
39
- downloads_path.mkdir(parents=True, exist_ok=True)
40
-
41
- file_name = f"{chave_acesso}.xml"
42
- file_path = downloads_path / file_name
43
-
44
- with open(file_path, 'w', encoding='utf-8') as f:
45
- f.write(xml_content)
46
-
47
- logger.info(f"XML salvo em {file_path}")
48
- return True
49
- except Exception as e:
50
- err_msg = f"Erro ao salvar o XML: {e}"
38
+ MAX_RETRIES = 3
39
+
40
+ for attempt in range(1, MAX_RETRIES + 1):
41
+ xml_content = await get_xml(chave_acesso)
42
+ if xml_content:
43
+ try:
44
+ downloads_path = Path.home() / "Downloads"
45
+ downloads_path.mkdir(parents=True, exist_ok=True)
46
+
47
+ file_name = f"{chave_acesso}.xml"
48
+ file_path = downloads_path / file_name
49
+
50
+ with open(file_path, "w", encoding="utf-8") as f:
51
+ f.write(xml_content)
52
+
53
+ logger.info(f"XML salvo em {file_path}")
54
+ return True
55
+ except Exception as e:
56
+ err_msg = f"Erro ao salvar o XML: {e}"
57
+ logger.error(err_msg)
58
+ else:
59
+ err_msg = "Não foi possível obter o XML."
51
60
  logger.error(err_msg)
52
- return False
53
- else:
54
- err_msg = "Não foi possível obter o XML."
55
- logger.error(err_msg)
56
- return False
61
+
62
+ if attempt < MAX_RETRIES:
63
+ await asyncio.sleep(2)
64
+
65
+ return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: worker-automate-hub
3
- Version: 0.5.37
3
+ Version: 0.5.38
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
@@ -1,6 +1,6 @@
1
1
  worker_automate_hub/__init__.py,sha256=LV28uQvBfpPIqudGIMJmVB8E941MjXHcu8DMoX5n8AM,25
2
2
  worker_automate_hub/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- worker_automate_hub/api/ahead_service.py,sha256=0tX-i1ACRg3_yOI-_AfFEZ6FNU3L8Zb316n3QUkSwL0,2027
3
+ worker_automate_hub/api/ahead_service.py,sha256=_zqvVOEYZm0khuzlUGipUpAW_is9nSC_H7gJ9WOoaP0,2230
4
4
  worker_automate_hub/api/client.py,sha256=tFrIr4mpjvUJ1uU--BCiWa3NT2Ru_yliBsWmfiGt1LA,19720
5
5
  worker_automate_hub/api/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  worker_automate_hub/api/helpers/api_helpers.py,sha256=SkheO2fXexeh-a4shr8Qzsz_kZhuSG0DJ7kbODctRbM,3696
@@ -75,7 +75,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
75
75
  worker_automate_hub/utils/util.py,sha256=famjVaoCDHLUoULQIGvqpVDu9gQihOLH2Nv1kCTsSqc,130967
76
76
  worker_automate_hub/utils/utils_nfe_entrada.py,sha256=ZTb1XoKWZY7coXt06iIE8KI56N6AguhZv5DEPX2qUu8,31862
77
77
  worker_automate_hub/worker.py,sha256=CT-poyP1ZYvubArYsnnNd9oJ53SPaDwgr6p6keS3nI4,6248
78
- worker_automate_hub-0.5.37.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
79
- worker_automate_hub-0.5.37.dist-info/METADATA,sha256=iV2-R2tLAOsXRUJqn8qgWjb_25OKpJaEGP0HYDDFmrU,2894
80
- worker_automate_hub-0.5.37.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
81
- worker_automate_hub-0.5.37.dist-info/RECORD,,
78
+ worker_automate_hub-0.5.38.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
79
+ worker_automate_hub-0.5.38.dist-info/METADATA,sha256=dyoCaTkXEmC5wHgl-NZ20vFy2b88rZfya_Hq_XOn4gw,2894
80
+ worker_automate_hub-0.5.38.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
81
+ worker_automate_hub-0.5.38.dist-info/RECORD,,