rpa-suite 1.5.5__py3-none-any.whl → 1.5.7__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.
rpa_suite/core/browser.py CHANGED
@@ -42,7 +42,7 @@ class Browser:
42
42
  Finds a single element on the page using the specified locator strategy.
43
43
  get(url: str, display_message: bool = False):
44
44
  Navigates the browser to the specified URL.
45
- _close_all_chrome():
45
+ _close_all_browsers():
46
46
  Closes all Chrome processes forcefully.
47
47
  close_browser(display_message: bool = False):
48
48
  Closes the browser instance and terminates the associated Chrome processes.
@@ -74,7 +74,7 @@ class Browser:
74
74
  Localiza um único elemento na página usando a estratégia de localização especificada.
75
75
  get(url: str, display_message: bool = False):
76
76
  Navega o navegador para a URL especificada.
77
- _close_all_chrome():
77
+ _close_all_browsers():
78
78
  Fecha todos os processos do Chrome de forma forçada.
79
79
  close_browser(display_message: bool = False):
80
80
  Fecha a instância do navegador e termina os processos associados do Chrome.
@@ -84,12 +84,12 @@ class Browser:
84
84
  port: int = None
85
85
  path_driver = None
86
86
 
87
- def __init__(self, port: int = 9393, close_all_chrome_on_this_port: bool = False):
87
+ def __init__(self, port: int = 9393, close_browser_on_this_port: bool = False):
88
88
  self.port = port
89
89
  self.path_driver = ChromeDriverManager().install()
90
90
 
91
- if close_all_chrome_on_this_port:
92
- self._close_all_chrome()
91
+ if close_browser_on_this_port:
92
+ self._close_all_browsers()
93
93
  ...
94
94
 
95
95
  def configure_browser(self) -> None:
@@ -168,7 +168,7 @@ class Browser:
168
168
  if response.status_code == 200:
169
169
  break # O Chrome está aberto
170
170
  except requests.ConnectionError:
171
- sleep(1) # Espera um segundo antes de tentar novamente
171
+ sleep(0.3) # Espera um segundo antes de tentar novamente
172
172
 
173
173
  # Inicializa o Chrome com as opções
174
174
  self.configure_browser()
@@ -199,7 +199,7 @@ class Browser:
199
199
  """
200
200
 
201
201
  try:
202
- sleep(2)
202
+ sleep(0.9)
203
203
  element = WebDriverWait(self.driver, timeout).until(
204
204
  EC.presence_of_element_located((by, value))
205
205
  )
@@ -285,7 +285,7 @@ class Browser:
285
285
  pass
286
286
 
287
287
  # Aguarda um momento para o processo ser liberado
288
- sleep(1)
288
+ sleep(0.6)
289
289
 
290
290
  # Força o fechamento do processo específico do Chrome
291
291
  os.system(
rpa_suite/core/log.py CHANGED
@@ -37,13 +37,10 @@ class CustomHandler:
37
37
 
38
38
  class CustomFormatter:
39
39
  def format(self, record):
40
- frame = inspect.currentframe().f_back
41
- full_path_filename = frame.f_code.co_filename
42
- filename = os.path.basename(full_path_filename)
43
- foldername = os.path.basename(os.path.dirname(full_path_filename))
44
- filename = os.path.join(foldername, filename)
45
- lineno = frame.f_lineno
46
- format_string = "<green>{time:DD.MM.YY.HH:mm}</green> <level>{level: <8}</level> <level>{message}</level>\n"
40
+ # Use the info from record["extra"] which is set in Log._log to the caller's file and line
41
+ filename = record["extra"].get("filename", "")
42
+ lineno = record["extra"].get("lineno", "")
43
+ format_string = "<green>{time:DD.MM.YY.HH:mm}</green> <level>{level: <8}</level> <green>{filename}</green>:<cyan>{lineno: <4}</cyan> <level>{message}</level>\n"
47
44
  log_msg = format_string.format(
48
45
  time=record["time"],
49
46
  level=record["level"].name,
@@ -101,7 +98,7 @@ class Log:
101
98
  file_handler = os.path.join(self.full_path, f"{self.name_file_log}.log")
102
99
  self.logger.remove()
103
100
 
104
- log_format = "<green>{time:DD.MM.YY.HH:mm}</green> <level>{level: <8}</level> <green>{extra[filename]}</green>:{extra[lineno]: <4} <level>{message}</level>"
101
+ log_format = "<green>{time:DD.MM.YY.HH:mm}</green> <level>{level: <8}</level> <green>{extra[filename]}</green>:<cyan>{extra[lineno]: <4}</cyan> <level>{message}</level>"
105
102
 
106
103
  formatter = CustomFormatter()
107
104
 
@@ -123,14 +120,36 @@ class Log:
123
120
  return None
124
121
 
125
122
  def _log(self, level: str, msg: str):
123
+ """
124
+ docstring
125
+ """
126
126
  try:
127
- frame = inspect.currentframe().f_back
127
+ # Find the first frame that's not from this log.py file
128
+ frame = inspect.currentframe()
129
+ current_file = os.path.normpath(__file__)
130
+
131
+ while frame:
132
+ frame = frame.f_back
133
+ if frame and os.path.normpath(frame.f_code.co_filename) != current_file:
134
+ break
135
+
136
+ if not frame:
137
+ # Fallback if we can't find external caller
138
+ frame = inspect.currentframe().f_back.f_back
139
+
128
140
  full_path_filename = frame.f_code.co_filename
129
- filename = os.path.basename(full_path_filename)
130
- foldername = os.path.basename(os.path.dirname(full_path_filename))
131
- filename = os.path.join(foldername, filename)
141
+
142
+ # Normalize path to use os.sep
143
+ full_path_filename = os.path.normpath(full_path_filename)
144
+
145
+ # Get the last two components: parent folder and filename
146
+ parent_folder = os.path.basename(os.path.dirname(full_path_filename))
147
+ file_name = os.path.basename(full_path_filename)
148
+ display_filename = f"{parent_folder}/{file_name}"
149
+
132
150
  lineno = frame.f_lineno
133
- self.logger.bind(filename=filename, lineno=lineno).log(level, msg)
151
+
152
+ self.logger.bind(filename=display_filename, lineno=lineno).log(level, msg)
134
153
  except Exception as e:
135
154
  error_print(f"Erro durante a função de log! Error: {str(e)}")
136
155
 
rpa_suite/suite.py CHANGED
@@ -16,7 +16,7 @@ from .core.asyncrun import AsyncRunner
16
16
 
17
17
  # imports external
18
18
  from colorama import Fore
19
- import pkg_resources
19
+ from importlib.metadata import version
20
20
 
21
21
  # imports third-party
22
22
  import subprocess
@@ -162,7 +162,10 @@ class Suite:
162
162
 
163
163
  # VARIABLES INTERNAL
164
164
  try:
165
- __version__ = pkg_resources.get_distribution("rpa_suite").version
165
+ # old: __version__ = pkg_resources.get_distribution("rpa_suite").version
166
+
167
+ __version__ = version("package_name")
168
+
166
169
  except Exception:
167
170
  __version__ = "unknown"
168
171
 
@@ -9,5 +9,7 @@ pt-br
9
9
  O módulo de utilitários da rpa-suite fornece uma coleção de funções e classes utilitárias que facilitam diversas tarefas na automação de processos. Inclui métodos auxiliares para registro de log, manipulação de arquivos e outras operações comuns que aprimoram a funcionalidade e a usabilidade da RPA Suite.
10
10
 
11
11
  """
12
+ from .system import Tools
13
+
12
14
 
13
15
  __version__ = '1.5.5'
rpa_suite/utils/system.py CHANGED
@@ -4,41 +4,153 @@
4
4
  from rpa_suite.functions._printer import error_print, success_print
5
5
 
6
6
  # imports third-party
7
- import sys, os
7
+ import sys, os, ctypes, traceback
8
8
 
9
9
 
10
- def set_importable_dir(display_message: bool = False):
10
+ class Utils:
11
11
  """
12
- Sets the directory to be importable by appending it to the system path.
12
+ Classe utilitária para gerenciamento de configurações de sistema e diretórios.
13
13
 
14
- Parameters:
15
- ----------
16
- display_message: bool - If True, displays a success message after setting the directory.
14
+ Fornece métodos para manipulação de caminhos de importação e configurações do sistema.
15
+ """
16
+
17
+ def __init__(self):
18
+ """
19
+ Inicializa a classe Utils.
20
+
21
+ Não requer parâmetros de inicialização específicos.
22
+ """
23
+ try:
24
+ pass
25
+ except Exception as e:
26
+ error_print(f"Erro durante a inicialização da classe Utils: {str(e)}")
27
+
28
+
29
+ def set_importable_dir(self, display_message: bool = False) -> None:
30
+ """
31
+ Configura o diretório atual como importável, adicionando-o ao caminho do sistema.
32
+
33
+ Adiciona o diretório pai do módulo atual ao sys.path, permitindo importações
34
+ dinâmicas de módulos locais.
35
+
36
+ Parâmetros:
37
+ ----------
38
+ display_message : bool, opcional
39
+ Se True, exibe uma mensagem de sucesso após definir o diretório.
40
+ Por padrão é False.
17
41
 
18
- Returns:
19
- ----------
42
+ Retorna:
43
+ --------
20
44
  None
21
45
 
22
- pt-br
23
- ----------
24
- Define o diretório para ser importável, adicionando-o ao caminho do sistema.
46
+ Exceções:
47
+ ---------
48
+ Captura e registra quaisquer erros durante o processo de configuração.
49
+ """
25
50
 
26
- Parâmetros:
27
- ----------
28
- display_message: bool - Se True, exibe uma mensagem de sucesso após definir o diretório.
51
+ try:
52
+ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
29
53
 
30
- Retornos:
31
- ----------
32
- Nenhum
54
+ if display_message:
55
+ success_print("Diretório configurado com sucesso para importação!")
56
+
57
+ except Exception as e:
58
+ error_print(
59
+ f"Erro ao configurar diretório importável: {str(e)}"
60
+ )
61
+
62
+
63
+ class KeepSessionActive:
33
64
  """
65
+ Gerenciador de contexto avançado para prevenir bloqueio de tela no Windows.
66
+
67
+ Utiliza chamadas de API do Windows para manter o sistema ativo durante
68
+ execução de tarefas críticas, impedindo suspensão ou bloqueio de tela.
69
+
70
+ Atributos de Classe:
71
+ -------------------
72
+ ES_CONTINUOUS : int
73
+ Flag para manter o estado de execução atual do sistema.
74
+ ES_SYSTEM_REQUIRED : int
75
+ Flag para prevenir a suspensão do sistema.
76
+ ES_DISPLAY_REQUIRED : int
77
+ Flag para manter o display ativo.
78
+
79
+ Exemplo de Uso:
80
+ --------------
81
+ with KeepSessionActive():
82
+ # Código que requer que o sistema permaneça ativo
83
+ realizar_tarefa_longa()
84
+ """
85
+
86
+ def __init__(self) -> None:
87
+ """
88
+ Inicializa as configurações de estado de execução do sistema.
89
+
90
+ Configura constantes específicas do Windows para controle de energia
91
+ e gerenciamento de estado do sistema operacional.
92
+ """
93
+ try:
94
+ self.ES_CONTINUOUS = 0x80000000
95
+ self.ES_SYSTEM_REQUIRED = 0x00000001
96
+ self.ES_DISPLAY_REQUIRED = 0x00000002
97
+ except Exception as e:
98
+ error_print(f"Erro ao inicializar KeepSessionActive: {str(e)}")
99
+
100
+
101
+ def __enter__(self) -> None:
102
+ """
103
+ Configura o estado de execução para prevenir bloqueio de tela.
104
+
105
+ Utiliza chamada de API do Windows para manter sistema e display ativos
106
+ durante a execução do bloco de código.
107
+
108
+ Retorna:
109
+ --------
110
+ KeepSessionActive
111
+ A própria instância do gerenciador de contexto.
112
+
113
+ Exceções:
114
+ ---------
115
+ Captura e registra quaisquer erros durante a configuração de estado.
116
+ """
117
+ try:
118
+ ctypes.windll.kernel32.SetThreadExecutionState(
119
+ self.ES_CONTINUOUS | self.ES_SYSTEM_REQUIRED | self.ES_DISPLAY_REQUIRED
120
+ )
121
+ return self
122
+ except Exception as e:
123
+ error_print(f"Erro ao configurar estado de execução: {str(e)}")
124
+ return self
125
+
126
+
127
+ def __exit__(self, exc_type, exc_val, exc_tb) -> None:
128
+ """
129
+ Restaura as configurações padrão de energia do sistema.
130
+
131
+ Método chamado automaticamente ao sair do bloco de contexto,
132
+ revertendo as configurações de estado de execução para o padrão.
133
+
134
+ Parâmetros:
135
+ ----------
136
+ exc_type : type, opcional
137
+ Tipo de exceção que pode ter ocorrido.
138
+ exc_val : Exception, opcional
139
+ Valor da exceção que pode ter ocorrido.
140
+ exc_tb : traceback, opcional
141
+ Traceback da exceção que pode ter ocorrido.
142
+
143
+ Exceções:
144
+ ---------
145
+ Captura e registra quaisquer erros durante a restauração do estado.
146
+ """
147
+ try:
148
+ ctypes.windll.kernel32.SetThreadExecutionState(self.ES_CONTINUOUS)
149
+ except Exception as e:
150
+ error_print(f"Erro ao restaurar estado de execução: {str(e)}")
34
151
 
35
- try:
36
- sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
37
152
 
38
- if display_message:
39
- success_print(f"Successfully set the directory for importation!")
40
153
 
41
- except Exception as e:
42
- error_print(
43
- f"An error occurred while executing the function: {set_importable_dir.__name__}! Error: {str(e)}."
44
- )
154
+ class Tools(Utils):
155
+
156
+ KeepSessionActive = KeepSessionActive
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rpa_suite
3
- Version: 1.5.5
3
+ Version: 1.5.7
4
4
  Summary: Conjunto de ferramentas essenciais para Automação RPA com Python, que facilitam o dia a dia de desenvolvimento.
5
5
  Author: Camilo Costa de Carvalho
6
6
  Author-email: camilo.carvalho@vettracode.com
@@ -284,10 +284,10 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
284
284
 
285
285
  ## Release Notes
286
286
 
287
- ### Versão: **Beta 1.5.5**
287
+ ### Versão: **Beta 1.5.7**
288
288
 
289
289
  - **Data de Lançamento:** *20/02/2024*
290
- - **Última Atualização:** 02/05/2025
290
+ - **Última Atualização:** 28/05/2025
291
291
  - **Status:** Em desenvolvimento
292
292
 
293
293
  Esta versão marca um grande avanço no desenvolvimento da RPA Suite, trazendo melhorias significativas na arquitetura, novas funcionalidades e maior simplicidade no uso. Confira as principais mudanças abaixo.
@@ -1,14 +1,14 @@
1
1
  rpa_suite/__init__.py,sha256=PGlr0Y0NLLH1sarD1VTv-Tvm_uZPmo1Ar4LLncvUVFU,2365
2
- rpa_suite/suite.py,sha256=DGP3zOW705qnv8EfFcXg75JIWQwibeIJID5kcmbFSQg,10556
2
+ rpa_suite/suite.py,sha256=fIbli4MCBVKXvv5JFmzudcEZATYMFyvx9rIK9CceorI,10648
3
3
  rpa_suite/core/__init__.py,sha256=clmYBLmsmFRXGMABUjIkV-dBe_OlviowszdIJEwS-yM,1748
4
4
  rpa_suite/core/asyncrun.py,sha256=bE04H36V01LavLRzGMhaUDBrnwhwLLSqpzKRZjsHVnA,4195
5
- rpa_suite/core/browser.py,sha256=Hpx4xJkg0KbBRgdYA5umYcOyHVYY-sz9k9ohBrk4uM0,15003
5
+ rpa_suite/core/browser.py,sha256=tew_SaTBVsWZHi66O41GOLMrdoR1XvgQmtoBMjGa9iE,15009
6
6
  rpa_suite/core/clock.py,sha256=T8ilbWrmGwhRGBAVRCCvICWQ1_uu2VjDTJgNEljPYhY,13414
7
7
  rpa_suite/core/date.py,sha256=42Nwvyx-FBBImEyVhBGksmIZ9VSwyFqhQPVeEwSpmtc,6310
8
8
  rpa_suite/core/dir.py,sha256=sN9R-XGIrySAyUYIB3XVHzaZR5ZqcX2Ag-pKZ6G3jpY,10301
9
9
  rpa_suite/core/email.py,sha256=kH6wFPxekXxhqt4ry_gWOzVeV_YBSIzb_xr5CL9FR_8,8741
10
10
  rpa_suite/core/file.py,sha256=plj_sC-j2j2IEQ5NRTssnSNPaPGLBg-RjPwGZPpWsIo,11441
11
- rpa_suite/core/log.py,sha256=LqH_sJ2ttAuW6qIhVP0x-gdDxBEzC1CoQCo_7VNgHSg,5869
11
+ rpa_suite/core/log.py,sha256=WAMGRwQr-zvl7eWR-JLJHQbq4NF4vN68MCc84QMnBfs,6568
12
12
  rpa_suite/core/parallel.py,sha256=nmATr6KimkAplDeh-dGwP6iB9muJ7ygDQ3NoYkEYgIg,11709
13
13
  rpa_suite/core/print.py,sha256=T-O4zaYzfPLKn5tEzgNrWOqRV_p4hAzT-c1Y3JDla24,5825
14
14
  rpa_suite/core/regex.py,sha256=76NjtLaIFM4LuTWLAOusQoOcP_Rub_G2ol9H6CIkTMg,3324
@@ -16,10 +16,10 @@ rpa_suite/core/validate.py,sha256=gOISOwjCza-18kfpaZnWCrKj4aIk2s7U4mStBDUAC7E,10
16
16
  rpa_suite/functions/__create_ss_dir.py,sha256=oAvZCMRgrBNUpaYGEiNlUFa1XiVYDfOqPb9M8ITxqG8,3482
17
17
  rpa_suite/functions/__init__.py,sha256=nXet0AfuyaazPrJUzfCgE382hONS3QqxDLydo75J6NU,57
18
18
  rpa_suite/functions/_printer.py,sha256=gj7dwOt4roSj2iwOGWeGgUD3JVr7h4UESyCg9CmrieA,3946
19
- rpa_suite/utils/__init__.py,sha256=Paz45Tn6mSyU0YcQLqvtBx4pOH1yoJVC1nlz4svtHTk,700
20
- rpa_suite/utils/system.py,sha256=Fum2VVXgBqWpS-f3Qj3u-sbWtW2dfCpKPRuipAY3x6c,1176
21
- rpa_suite-1.5.5.dist-info/licenses/LICENSE,sha256=5D8PIbs31iGd9i1_MDNg4SzaQnp9sEIULALh2y3WyMI,1102
22
- rpa_suite-1.5.5.dist-info/METADATA,sha256=6V1UAxuE8DBMLcv7YO5VVzTK4hgv7WuxG-6XgHNE-lo,13938
23
- rpa_suite-1.5.5.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
24
- rpa_suite-1.5.5.dist-info/top_level.txt,sha256=HYkDtg-kJNAr3F2XAIPyJ-QBbNhk7q6jrqsFt10lz4Y,10
25
- rpa_suite-1.5.5.dist-info/RECORD,,
19
+ rpa_suite/utils/__init__.py,sha256=FeMyn0dSuj8gMBrvzk-61mkz4F_hPT6l--vDyMWjxYw,729
20
+ rpa_suite/utils/system.py,sha256=KUx3yisPr-eSnORgcBVcGUypoW-xef2e-l5odLAYrnQ,5012
21
+ rpa_suite-1.5.7.dist-info/licenses/LICENSE,sha256=5D8PIbs31iGd9i1_MDNg4SzaQnp9sEIULALh2y3WyMI,1102
22
+ rpa_suite-1.5.7.dist-info/METADATA,sha256=EcOxaInP0RQJUwwZwKprf7nSuc2f-61TpMsbxjZG2sU,13938
23
+ rpa_suite-1.5.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
+ rpa_suite-1.5.7.dist-info/top_level.txt,sha256=HYkDtg-kJNAr3F2XAIPyJ-QBbNhk7q6jrqsFt10lz4Y,10
25
+ rpa_suite-1.5.7.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5