rpa-suite 1.4.1__tar.gz → 1.4.5__tar.gz
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-1.4.1 → rpa_suite-1.4.5}/PKG-INFO +25 -15
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/README.md +24 -14
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/__init__.py +5 -1
- rpa_suite-1.4.5/rpa_suite/core/__init__.py +28 -0
- rpa_suite-1.4.5/rpa_suite/core/browser.py +166 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/core/clock.py +9 -5
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/core/email.py +40 -14
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/core/file.py +39 -32
- rpa_suite-1.4.5/rpa_suite/core/log.py +139 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/suite.py +36 -23
- rpa_suite-1.4.5/rpa_suite/utils/__init__.py +10 -0
- rpa_suite-1.4.5/rpa_suite/utils/system.py +33 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite.egg-info/PKG-INFO +25 -15
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite.egg-info/SOURCES.txt +4 -1
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/setup.py +1 -1
- rpa_suite-1.4.1/rpa_suite/core/__init__.py +0 -1
- rpa_suite-1.4.1/rpa_suite/core/log.py +0 -465
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/LICENSE +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/core/date.py +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/core/dir.py +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/core/print.py +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/core/regex.py +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/core/validate.py +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/functions/__create_log_dir.py +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/functions/__create_ss_dir.py +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/functions/__init__.py +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/functions/_functions_logger.py +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/functions/_logger.py +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/functions/_printer.py +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/functions/_variables.py +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite/functions/_variables_uru.py +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite.egg-info/dependency_links.txt +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite.egg-info/requires.txt +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/rpa_suite.egg-info/top_level.txt +0 -0
- {rpa_suite-1.4.1 → rpa_suite-1.4.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: rpa_suite
|
3
|
-
Version: 1.4.
|
3
|
+
Version: 1.4.5
|
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@triasoftware.com.br
|
@@ -145,6 +145,14 @@ No setup do nosso projeto já estão inclusas as dependências, só será necess
|
|
145
145
|
- loguru
|
146
146
|
- email-validator
|
147
147
|
- colorlog
|
148
|
+
- pillow
|
149
|
+
- pyautogui
|
150
|
+
- typing
|
151
|
+
|
152
|
+
opcionalmente para automação de navegador:
|
153
|
+
|
154
|
+
- selenium
|
155
|
+
- webdriver_manager
|
148
156
|
|
149
157
|
[!IMPORTANT]
|
150
158
|
No caso da função de screenshot é necessario ter as libs 'pyautogui' 'pillow' e 'pyscreeze' instalados, geralmente a instalação de pyautogui já instala as demais dependências deste caso.
|
@@ -153,6 +161,8 @@ No caso da função de screenshot é necessario ter as libs 'pyautogui' 'pillow'
|
|
153
161
|
|
154
162
|
O módulo principal do rpa-suite é dividido em categorias. Cada categoria contém módulos com funções destinadas a cada tipo de tarefa
|
155
163
|
|
164
|
+
! Divisao e nomes de funções precisam ser atualizadas nesta sessão de Estrutura do módulo !
|
165
|
+
|
156
166
|
- **rpa_suite**
|
157
167
|
- **clock**
|
158
168
|
- **waiter** - Função capaz de aguardar para executar a função do argumento, ou executar a função do argumento para aguardar posteriormente
|
@@ -178,26 +188,26 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
|
|
178
188
|
|
179
189
|
## Release
|
180
190
|
|
181
|
-
Versão: **Beta 1.
|
191
|
+
Versão: **Beta 1.4.5**
|
182
192
|
|
183
193
|
Lançamento: *20/02/2024*
|
184
194
|
|
185
|
-
Última atualização: *10/
|
195
|
+
Última atualização: *10/04/2025*
|
186
196
|
|
187
197
|
Status: Em desenvolvimento.
|
188
198
|
|
189
|
-
### Notas da atualização: 1.4.
|
190
|
-
|
191
|
-
-
|
192
|
-
-
|
193
|
-
-
|
194
|
-
-
|
195
|
-
-
|
196
|
-
-
|
197
|
-
-
|
198
|
-
-
|
199
|
-
-
|
200
|
-
-
|
199
|
+
### Notas da atualização: 1.4.5
|
200
|
+
|
201
|
+
- Mudança dos submodulos para Objetos, agora Rpa_suite é um Objeto de Suite que compoe diversos sub-objetos separados pelas mesmas categorias anteriormente ja definidas
|
202
|
+
- Reformulada a arquitetura do projeto para melhor coeção e menos subpastas e arquivos, agora a estrutura é mais simples e de melhor manutenção contendo apenas uma pasta core para o nucleo de nossos modulos, e uma pasta utils com ferramentas utilitarias que vamos adicionar varias novidades
|
203
|
+
- Adicionado setor utils com funcionalidade de tornar o diretorio atual em um importavel relativo para o python
|
204
|
+
- Adicionado Automação de Navegadores! Sim estamos devendo esta feature a bastante tempo, porem estamos com a primeira versão disponivel, em breve teremos mais recursos e disponibilidade para outros navegadores, atualmente suporte apenas para *Chrome.*
|
205
|
+
- Mantemos o alerta! **get_dma** atualizada e **renomeada** para **get_dmy** para manter o padrão em ingles
|
206
|
+
- Função *send_email* atualizada para simplificar seu uso e funcionalidade em uma maior variedade de maquinas
|
207
|
+
- Melhoria nas descrições das funções e adicionado docstring (documentação explicativa) de todos Objetos e respectivas funções
|
208
|
+
- Sub-modulos agora como são Objetos internos do Objeto principal Suite pode ser acessado de duas formas, ex1: " from rpa_suite import rpa ; rpa.modulo.function() " ou então ex2: "from rpa_suite.core.Submodulo import NomeModulo ; meu_obj = NomeModulo() ; meu_obj.function()",
|
209
|
+
- Funções de regex e busca em textos foi simplificada e em breve estaremos adicionando funcionalidades mais interessantes.
|
210
|
+
- Correção e melhoria do Submodulo de Log. Tinhamos dois formatos de Log com duas bibliotecas e decidimos optar apenas pela Loguru para podermos dedicar mais atenção e fornecer recursos de Log mais completos, agora possui funcionalidade para indicar o caminho da pasta, nome da pasta, e também nome do arquivo, realizando stream tanto para o console (terminal) como também para o arquivo com todos levels já configurados e personalizados para ter distinção e facilitar o reconhecimento visual do que esta acontecendo no seu projeto.
|
201
211
|
|
202
212
|
## Mais Sobre
|
203
213
|
|
@@ -107,6 +107,14 @@ No setup do nosso projeto já estão inclusas as dependências, só será necess
|
|
107
107
|
- loguru
|
108
108
|
- email-validator
|
109
109
|
- colorlog
|
110
|
+
- pillow
|
111
|
+
- pyautogui
|
112
|
+
- typing
|
113
|
+
|
114
|
+
opcionalmente para automação de navegador:
|
115
|
+
|
116
|
+
- selenium
|
117
|
+
- webdriver_manager
|
110
118
|
|
111
119
|
[!IMPORTANT]
|
112
120
|
No caso da função de screenshot é necessario ter as libs 'pyautogui' 'pillow' e 'pyscreeze' instalados, geralmente a instalação de pyautogui já instala as demais dependências deste caso.
|
@@ -115,6 +123,8 @@ No caso da função de screenshot é necessario ter as libs 'pyautogui' 'pillow'
|
|
115
123
|
|
116
124
|
O módulo principal do rpa-suite é dividido em categorias. Cada categoria contém módulos com funções destinadas a cada tipo de tarefa
|
117
125
|
|
126
|
+
! Divisao e nomes de funções precisam ser atualizadas nesta sessão de Estrutura do módulo !
|
127
|
+
|
118
128
|
- **rpa_suite**
|
119
129
|
- **clock**
|
120
130
|
- **waiter** - Função capaz de aguardar para executar a função do argumento, ou executar a função do argumento para aguardar posteriormente
|
@@ -140,26 +150,26 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
|
|
140
150
|
|
141
151
|
## Release
|
142
152
|
|
143
|
-
Versão: **Beta 1.
|
153
|
+
Versão: **Beta 1.4.5**
|
144
154
|
|
145
155
|
Lançamento: *20/02/2024*
|
146
156
|
|
147
|
-
Última atualização: *10/
|
157
|
+
Última atualização: *10/04/2025*
|
148
158
|
|
149
159
|
Status: Em desenvolvimento.
|
150
160
|
|
151
|
-
### Notas da atualização: 1.4.
|
152
|
-
|
153
|
-
-
|
154
|
-
-
|
155
|
-
-
|
156
|
-
-
|
157
|
-
-
|
158
|
-
-
|
159
|
-
-
|
160
|
-
-
|
161
|
-
-
|
162
|
-
-
|
161
|
+
### Notas da atualização: 1.4.5
|
162
|
+
|
163
|
+
- Mudança dos submodulos para Objetos, agora Rpa_suite é um Objeto de Suite que compoe diversos sub-objetos separados pelas mesmas categorias anteriormente ja definidas
|
164
|
+
- Reformulada a arquitetura do projeto para melhor coeção e menos subpastas e arquivos, agora a estrutura é mais simples e de melhor manutenção contendo apenas uma pasta core para o nucleo de nossos modulos, e uma pasta utils com ferramentas utilitarias que vamos adicionar varias novidades
|
165
|
+
- Adicionado setor utils com funcionalidade de tornar o diretorio atual em um importavel relativo para o python
|
166
|
+
- Adicionado Automação de Navegadores! Sim estamos devendo esta feature a bastante tempo, porem estamos com a primeira versão disponivel, em breve teremos mais recursos e disponibilidade para outros navegadores, atualmente suporte apenas para *Chrome.*
|
167
|
+
- Mantemos o alerta! **get_dma** atualizada e **renomeada** para **get_dmy** para manter o padrão em ingles
|
168
|
+
- Função *send_email* atualizada para simplificar seu uso e funcionalidade em uma maior variedade de maquinas
|
169
|
+
- Melhoria nas descrições das funções e adicionado docstring (documentação explicativa) de todos Objetos e respectivas funções
|
170
|
+
- Sub-modulos agora como são Objetos internos do Objeto principal Suite pode ser acessado de duas formas, ex1: " from rpa_suite import rpa ; rpa.modulo.function() " ou então ex2: "from rpa_suite.core.Submodulo import NomeModulo ; meu_obj = NomeModulo() ; meu_obj.function()",
|
171
|
+
- Funções de regex e busca em textos foi simplificada e em breve estaremos adicionando funcionalidades mais interessantes.
|
172
|
+
- Correção e melhoria do Submodulo de Log. Tinhamos dois formatos de Log com duas bibliotecas e decidimos optar apenas pela Loguru para podermos dedicar mais atenção e fornecer recursos de Log mais completos, agora possui funcionalidade para indicar o caminho da pasta, nome da pasta, e também nome do arquivo, realizando stream tanto para o console (terminal) como também para o arquivo com todos levels já configurados e personalizados para ter distinção e facilitar o reconhecimento visual do que esta acontecendo no seu projeto.
|
163
173
|
|
164
174
|
## Mais Sobre
|
165
175
|
|
@@ -26,6 +26,7 @@
|
|
26
26
|
``printer``: Functions for formatted output
|
27
27
|
``regex``: Operations with regular expressions
|
28
28
|
``validate``: Data validation functions
|
29
|
+
``Browser``: Object Browser automation functions
|
29
30
|
|
30
31
|
pt-br
|
31
32
|
-----
|
@@ -55,5 +56,8 @@
|
|
55
56
|
``printer``: Funções para output formatado
|
56
57
|
``regex``: Operações com expressões regulares
|
57
58
|
``validate``: Funções de validação de dados
|
59
|
+
``Browser``: Objeto de Automação de Navegadores
|
58
60
|
"""
|
59
|
-
|
61
|
+
|
62
|
+
from .suite import rpa
|
63
|
+
rpa
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# rpa_suite/core/__init__.py
|
2
|
+
|
3
|
+
"""
|
4
|
+
The Core module is where we can import all Sub-Objects used by the rpa_suite module separately, categorized by their respective classes based on functionality. However, we can also use them through the main rpa object using the following syntax:
|
5
|
+
>>> from rpa_suite import rpa
|
6
|
+
>>> rpa.clock.wait_for_exec()
|
7
|
+
>>> rpa.file.screen_shot() ...
|
8
|
+
among others.
|
9
|
+
|
10
|
+
pt-br
|
11
|
+
----------
|
12
|
+
O módulo Core é de onde podemos importar todos os Sub-Objetos usados pelo módulo rpa_suite de forma separada, categorizados por suas respectivas classes com base na funcionalidade. No entanto, também podemos usá-los através do objeto principal rpa usando a seguinte sintaxe:
|
13
|
+
>>> from rpa_suite import rpa
|
14
|
+
>>> rpa.clock.wait_for_exec()
|
15
|
+
>>> rpa.file.screen_shot() ...
|
16
|
+
entre outros.
|
17
|
+
|
18
|
+
"""
|
19
|
+
from .clock import Clock
|
20
|
+
from .date import Date
|
21
|
+
from .dir import Directory
|
22
|
+
from .email import Email
|
23
|
+
from .file import File
|
24
|
+
from .log import Log
|
25
|
+
from .print import Print
|
26
|
+
from .regex import Regex
|
27
|
+
from .validate import Validate
|
28
|
+
from .browser import Browser
|
@@ -0,0 +1,166 @@
|
|
1
|
+
# default import
|
2
|
+
import os, requests
|
3
|
+
|
4
|
+
# imports
|
5
|
+
from rpa_suite.functions._printer import error_print, alert_print, success_print
|
6
|
+
|
7
|
+
from selenium import webdriver
|
8
|
+
from selenium.webdriver.common.by import By
|
9
|
+
from selenium.webdriver.chrome.options import Options
|
10
|
+
from selenium.webdriver.support.ui import WebDriverWait
|
11
|
+
from selenium.webdriver.support import expected_conditions as EC
|
12
|
+
from webdriver_manager.chrome import ChromeDriverManager
|
13
|
+
from time import sleep
|
14
|
+
|
15
|
+
class Browser():
|
16
|
+
|
17
|
+
"""
|
18
|
+
WIP ...
|
19
|
+
"""
|
20
|
+
|
21
|
+
driver: None
|
22
|
+
port: int = None
|
23
|
+
path_driver = None
|
24
|
+
|
25
|
+
def __init__(self, port: int = 9393, close_all_chrome_on_this_port: bool = True):
|
26
|
+
self.port = port
|
27
|
+
self.path_driver = ChromeDriverManager().install()
|
28
|
+
|
29
|
+
if close_all_chrome_on_this_port: self._close_all_chrome()
|
30
|
+
...
|
31
|
+
|
32
|
+
def configure_browser(self) -> None:
|
33
|
+
|
34
|
+
try:
|
35
|
+
# Use the absolute path from comment
|
36
|
+
|
37
|
+
options = Options()
|
38
|
+
options.add_experimental_option("debuggerAddress",
|
39
|
+
f"127.0.0.1:{str(self.port)}")
|
40
|
+
|
41
|
+
# Additional configs
|
42
|
+
options.add_argument("--start-maximized")
|
43
|
+
options.add_argument("--disable-notifications")
|
44
|
+
|
45
|
+
# Verifica se o caminho do driver está correto
|
46
|
+
if not os.path.exists(self.path_driver):
|
47
|
+
raise FileNotFoundError(f'O caminho do driver não foi encontrado: {self.path_driver}')
|
48
|
+
|
49
|
+
# Create driver with options and chromedriver path
|
50
|
+
self.driver = webdriver.Chrome(
|
51
|
+
#service=self.path_driver,
|
52
|
+
options=options,
|
53
|
+
keep_alive=True
|
54
|
+
)
|
55
|
+
|
56
|
+
except Exception as e:
|
57
|
+
error_print(f'Erro durante a função: {self.configure_browser.__name__}! Error: {str(e)}.')
|
58
|
+
|
59
|
+
def start_browser(self, close_chrome_on_this_port: bool = True, display_message: bool = False):
|
60
|
+
|
61
|
+
try:
|
62
|
+
if close_chrome_on_this_port: self.close_browser()
|
63
|
+
|
64
|
+
# Inicia o Chrome com debugging port
|
65
|
+
os.system(f'start chrome.exe --remote-debugging-port={str(self.port)} --user-data-dir="C:/temp/chrome_profile"')
|
66
|
+
|
67
|
+
# Aguardar até que o Chrome esteja realmente aberto
|
68
|
+
while True:
|
69
|
+
try:
|
70
|
+
# Tenta conectar ao Chrome na porta de depuração
|
71
|
+
response = requests.get(f'http://127.0.0.1:{self.port}/json')
|
72
|
+
if response.status_code == 200:
|
73
|
+
break # O Chrome está aberto
|
74
|
+
except requests.ConnectionError:
|
75
|
+
sleep(1) # Espera um segundo antes de tentar novamente
|
76
|
+
|
77
|
+
# Inicializa o Chrome com as opções
|
78
|
+
self.configure_browser()
|
79
|
+
|
80
|
+
if display_message: success_print(f'Browser: Iniciado com sucesso!')
|
81
|
+
|
82
|
+
except Exception as e:
|
83
|
+
error_print(f'Erro ao iniciar navegador: {str(e)}.')
|
84
|
+
|
85
|
+
|
86
|
+
def find_ele(self, value, by=By.XPATH, timeout=12, display_message=True):
|
87
|
+
|
88
|
+
try:
|
89
|
+
sleep(2)
|
90
|
+
element = WebDriverWait(self.driver, timeout).until(
|
91
|
+
EC.presence_of_element_located((by, value))
|
92
|
+
); return element
|
93
|
+
|
94
|
+
except Exception as e:
|
95
|
+
|
96
|
+
if display_message:
|
97
|
+
error_print(f'Erro durante a função: {self.find_ele.__name__}! Error: {str(e)}.')
|
98
|
+
return None
|
99
|
+
else: return None
|
100
|
+
|
101
|
+
# find elements (needs implementation)
|
102
|
+
...
|
103
|
+
|
104
|
+
# navigate
|
105
|
+
def get(self, url: str, display_message: bool = False):
|
106
|
+
|
107
|
+
try:
|
108
|
+
self.driver.get(url)
|
109
|
+
if display_message: success_print(f'Browser: Navegando para: {url}')
|
110
|
+
|
111
|
+
except Exception as e:
|
112
|
+
error_print(f'Erro ao navegar para a URL: {url}. Error: {str(e)}.')
|
113
|
+
|
114
|
+
|
115
|
+
def _close_all_chrome(self):
|
116
|
+
|
117
|
+
try:
|
118
|
+
os.system('taskkill /F /IM chrome.exe >nul 2>&1')
|
119
|
+
except:
|
120
|
+
pass
|
121
|
+
|
122
|
+
|
123
|
+
def close_browser(self, display_message: bool = False):
|
124
|
+
|
125
|
+
try:
|
126
|
+
# Primeiro tenta fechar todas as janelas via Selenium
|
127
|
+
try:
|
128
|
+
self.driver.close()
|
129
|
+
except:
|
130
|
+
pass
|
131
|
+
|
132
|
+
# Depois tenta encerrar a sessão
|
133
|
+
try:
|
134
|
+
self.driver.quit()
|
135
|
+
except:
|
136
|
+
pass
|
137
|
+
|
138
|
+
# Aguarda um momento para o processo ser liberado
|
139
|
+
sleep(1)
|
140
|
+
|
141
|
+
# Força o fechamento do processo específico do Chrome
|
142
|
+
os.system(f'taskkill /f /im chrome.exe /fi "commandline like *--remote-debugging-port={str(self.port)}*" >nul 2>&1')
|
143
|
+
|
144
|
+
# Verifica se o processo foi realmente terminado
|
145
|
+
check = os.system(f'tasklist /fi "imagename eq chrome.exe" /fi "commandline like *--remote-debugging-port={str(self.port)}*" >nul 2>&1')
|
146
|
+
|
147
|
+
if check == 0:
|
148
|
+
# Processo ainda existe, tenta método mais agressivo
|
149
|
+
os.system(f'taskkill /f /im chrome.exe /fi "commandline like *--remote-debugging-port={str(self.port)}*" /t >nul 2>&1')
|
150
|
+
if display_message: alert_print(f'Browser: Fechado via força!')
|
151
|
+
|
152
|
+
else:
|
153
|
+
if display_message: success_print(f'Browser: Fechado com sucesso!')
|
154
|
+
|
155
|
+
except Exception as e:
|
156
|
+
|
157
|
+
|
158
|
+
try:
|
159
|
+
if display_message: alert_print(f'Erro ao fechar navegador: {str(e)}, Tentando meio mais forte!')
|
160
|
+
|
161
|
+
# Último recurso - mata todos os processos do Chrome (use com cautela)
|
162
|
+
os.system(f'taskkill /f /im chrome.exe /fi "commandline like *--remote-debugging-port={str(self.port)}*" /t >nul 2>&1')
|
163
|
+
if display_message: alert_print(f'Browser: Fechado via força extrema!')
|
164
|
+
|
165
|
+
except Exception as error_ultimate:
|
166
|
+
if display_message: error_print(f'Falha crítica ao tentar fechar o navegador! Error: {str(error_ultimate)}!')
|
@@ -7,6 +7,7 @@ from typing import Callable, Any
|
|
7
7
|
|
8
8
|
|
9
9
|
class Clock():
|
10
|
+
|
10
11
|
"""
|
11
12
|
Class that provides utilities for time manipulation and stopwatch.
|
12
13
|
|
@@ -38,11 +39,12 @@ class Clock():
|
|
38
39
|
>>> from rpa_suite import rpa
|
39
40
|
>>> rpa.clock.exec_at_hour("14:30", minha_funcao)
|
40
41
|
"""
|
42
|
+
|
41
43
|
def __init__(self):
|
42
44
|
...
|
43
|
-
|
45
|
+
|
44
46
|
def exec_at_hour(self,
|
45
|
-
hour_to_exec: str,
|
47
|
+
hour_to_exec: str | None,
|
46
48
|
fn_to_exec: Callable[..., Any],
|
47
49
|
*args,
|
48
50
|
**kwargs,
|
@@ -190,7 +192,8 @@ class Clock():
|
|
190
192
|
>>> wait_for_exec(30, sum, 10, 5) -> 15 \n
|
191
193
|
* NOTE: `wait_for_exec` receives as first argument the time to wait (sec), then the function `sum` and finally the arguments that the function will use.
|
192
194
|
|
193
|
-
|
195
|
+
|
196
|
+
pt-br
|
194
197
|
----------
|
195
198
|
Função temporizadora, aguardar um valor em ``segundos`` para executar a função do argumento.
|
196
199
|
|
@@ -257,8 +260,9 @@ class Clock():
|
|
257
260
|
We have a sum function in the following format ``sum(a, b) -> return x``, where ``x`` is the result of the sum. We want to execute the sum and then wait `30 seconds` to continue the main code:
|
258
261
|
>>> wait_for_exec(30, sum, 10, 5) -> 15 \n
|
259
262
|
* NOTE: `wait_for_exec` receives as first argument the time to wait (sec), then the function `sum` and finally the arguments that the function will use.
|
260
|
-
|
261
|
-
|
263
|
+
|
264
|
+
|
265
|
+
pt-br
|
262
266
|
----------
|
263
267
|
Função temporizadora, executa uma função e aguarda o tempo em ``segundos``
|
264
268
|
|
@@ -99,28 +99,54 @@ class Email():
|
|
99
99
|
):
|
100
100
|
|
101
101
|
"""
|
102
|
-
|
102
|
+
Sends an email using the specified SMTP server.
|
103
103
|
|
104
104
|
Args:
|
105
|
-
smtp_server (str, optional):
|
105
|
+
smtp_server (str, optional): Address of the SMTP server.
|
106
|
+
Default: "smtp.hostinger.com".
|
107
|
+
smtp_port (str, optional): Port of the SMTP server.
|
108
|
+
Default: 465.
|
109
|
+
email_user (str, optional): User (email) for authentication on the SMTP server.
|
110
|
+
Default: "example@email.com".
|
111
|
+
email_password (str, optional): Password for authentication on the SMTP server.
|
112
|
+
Default: "example123".
|
113
|
+
email_to (str, optional): Email address of the recipient.
|
114
|
+
Default: "person@email.com".
|
115
|
+
attachments (list[str], optional): List of file paths to attach to the email.
|
116
|
+
Default: [].
|
117
|
+
subject_title (str, optional): Title (subject) of the email.
|
118
|
+
Default: 'test title'.
|
119
|
+
body_message (str, optional): Body of the email message, in HTML format.
|
120
|
+
Default: '<p>test message</p>'.
|
121
|
+
|
122
|
+
Returns:
|
123
|
+
None: This function does not explicitly return any value, but prints success or failure messages when sending the email.
|
124
|
+
|
125
|
+
pt-br
|
126
|
+
------
|
127
|
+
|
128
|
+
Envia um email usando o servidor SMTP especificado.
|
129
|
+
|
130
|
+
Args:
|
131
|
+
smtp_server (str, opcional): Endereço do servidor SMTP.
|
106
132
|
Padrão: "smtp.hostinger.com".
|
107
|
-
smtp_port (str,
|
133
|
+
smtp_port (str, opcional): Porta do servidor SMTP.
|
108
134
|
Padrão: 465.
|
109
|
-
email_user (str,
|
110
|
-
Padrão: "
|
111
|
-
email_password (str,
|
112
|
-
Padrão: "
|
113
|
-
email_to (str,
|
114
|
-
Padrão: "
|
115
|
-
attachments (list[str],
|
135
|
+
email_user (str, opcional): Usuário (email) para autenticação no servidor SMTP.
|
136
|
+
Padrão: "example@email.com".
|
137
|
+
email_password (str, opcional): Senha para autenticação no servidor SMTP.
|
138
|
+
Padrão: "example123".
|
139
|
+
email_to (str, opcional): Endereço de email do destinatário.
|
140
|
+
Padrão: "person@email.com".
|
141
|
+
attachments (list[str], opcional): Lista de caminhos de arquivos para anexar ao email.
|
116
142
|
Padrão: [].
|
117
|
-
subject_title (str,
|
118
|
-
Padrão: '
|
119
|
-
body_message (str,
|
143
|
+
subject_title (str, opcional): Título (assunto) do email.
|
144
|
+
Padrão: 'título de teste'.
|
145
|
+
body_message (str, opcional): Corpo da mensagem do email, em formato HTML.
|
120
146
|
Padrão: '<p>mensagem de teste</p>'.
|
121
147
|
|
122
148
|
Returns:
|
123
|
-
|
149
|
+
Nenhum: Esta função não retorna explicitamente nenhum valor, mas imprime mensagens de sucesso ou falha ao enviar o email.
|
124
150
|
"""
|
125
151
|
|
126
152
|
try:
|
@@ -7,54 +7,55 @@ from typing import Dict, List, Union
|
|
7
7
|
|
8
8
|
class File():
|
9
9
|
"""
|
10
|
-
Class that provides utilities for file management, including
|
10
|
+
Class that provides utilities for file management, including creation, deletion, and manipulation of files.
|
11
11
|
|
12
12
|
This class offers functionalities for:
|
13
|
-
- Creating files
|
14
|
-
-
|
15
|
-
-
|
16
|
-
- File path management
|
13
|
+
- Creating and deleting flag files
|
14
|
+
- Counting files in a directory
|
15
|
+
- Capturing screenshots and managing their paths
|
17
16
|
|
18
17
|
Methods:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
screen_shot: Creates a screenshot and saves it in a specified directory
|
19
|
+
count_files: Counts the number of files in a specified directory
|
20
|
+
flag_create: Creates a flag file
|
21
|
+
flag_delete: Deletes a flag file
|
23
22
|
|
24
|
-
The File class is part of RPA Suite and can be accessed through the rpa object:
|
23
|
+
The File class is part of the RPA Suite and can be accessed through the rpa object:
|
25
24
|
>>> from rpa_suite import rpa
|
26
|
-
>>> rpa.file.
|
25
|
+
>>> rpa.file.screen_shot('example')
|
27
26
|
|
28
27
|
Parameters:
|
29
|
-
file_name (str): The name of the file
|
30
|
-
|
31
|
-
|
28
|
+
file_name (str): The name of the screenshot file
|
29
|
+
path_dir (str): The path of the directory where the screenshot should be saved
|
30
|
+
save_with_date (bool): Indicates if the file name should include the date
|
31
|
+
delay (int): The wait time before capturing the screen
|
32
32
|
|
33
33
|
pt-br
|
34
34
|
----------
|
35
35
|
Classe que fornece utilitários para gerenciamento de arquivos, incluindo criação, exclusão e manipulação de arquivos.
|
36
36
|
|
37
37
|
Esta classe oferece funcionalidades para:
|
38
|
-
- Criar arquivos
|
39
|
-
-
|
40
|
-
-
|
41
|
-
- Gerenciamento de caminhos de arquivos
|
38
|
+
- Criar e excluir arquivos de flag
|
39
|
+
- Contar arquivos em um diretório
|
40
|
+
- Capturar screenshots e gerenciar seus caminhos
|
42
41
|
|
43
42
|
Métodos:
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
screen_shot: Cria uma captura de tela e a salva em um diretório especificado
|
44
|
+
count_files: Conta o número de arquivos em um diretório especificado
|
45
|
+
flag_create: Cria um arquivo de flag
|
46
|
+
flag_delete: Exclui um arquivo de flag
|
48
47
|
|
49
48
|
A classe File é parte do RPA Suite e pode ser acessada através do objeto rpa:
|
50
49
|
>>> from rpa_suite import rpa
|
51
|
-
>>> rpa.file.
|
50
|
+
>>> rpa.file.screen_shot('exemplo')
|
52
51
|
|
53
52
|
Parâmetros:
|
54
|
-
file_name (str): O nome do arquivo
|
55
|
-
|
56
|
-
|
53
|
+
file_name (str): O nome do arquivo de captura de tela
|
54
|
+
path_dir (str): O caminho do diretório onde a captura de tela deve ser salva
|
55
|
+
save_with_date (bool): Indica se o nome do arquivo deve incluir a data
|
56
|
+
delay (int): O tempo de espera antes de capturar a tela
|
57
57
|
"""
|
58
|
+
|
58
59
|
def __init__(self):
|
59
60
|
self.__create_ss_dir = create_ss_dir
|
60
61
|
|
@@ -64,7 +65,7 @@ class File():
|
|
64
65
|
save_with_date: bool = True,
|
65
66
|
delay: int = 1,
|
66
67
|
use_default_path_and_name: bool = True,
|
67
|
-
name_ss_dir:str = None,
|
68
|
+
name_ss_dir:str | None = None,
|
68
69
|
display_message: bool = False) -> str | None:
|
69
70
|
|
70
71
|
"""
|
@@ -72,10 +73,13 @@ class File():
|
|
72
73
|
|
73
74
|
Parameters:
|
74
75
|
----------
|
75
|
-
``file_path: str`` - should be a string, not have a default path.
|
76
76
|
``file_name: str`` - should be a string, by default name is `screenshot`.
|
77
|
+
``path_dir: str`` - should be a string, not have a default path.
|
77
78
|
``save_with_date: bool`` - should be a boolean, by default `True` save namefile with date `foo_dd_mm_yyyy-hh_mm_ss.png`.
|
78
79
|
``delay: int`` - should be a int, by default 1 (represents seconds).
|
80
|
+
``use_default_path_and_name: bool`` - should be a boolean, by default `True`
|
81
|
+
``name_ss_dir: str`` - should be a string, by default type `None`
|
82
|
+
``display_message`` - should be a boolean, by default `False`
|
79
83
|
|
80
84
|
Return:
|
81
85
|
----------
|
@@ -88,10 +92,13 @@ class File():
|
|
88
92
|
|
89
93
|
Parâmetros:
|
90
94
|
----------
|
91
|
-
``file_path: str`` - deve ser uma string, não tem um caminho padrão.
|
92
95
|
``file_name: str`` - deve ser uma string, por padrão o nome é `screenshot`.
|
96
|
+
``file_path: str`` - deve ser uma string, não tem um caminho padrão.
|
93
97
|
``save_with_date: bool`` - deve ser um booleano, por padrão `True` salva o nome do arquivo com a data `foo_dd_mm_yyyy-hh_mm_ss.png`.
|
94
98
|
``delay: int`` - deve ser um int, por padrão 1 representado em segundo(s).
|
99
|
+
``use_default_path_and_name: bool`` - deve ser um booleano, por padrão `True`
|
100
|
+
``name_ss_dir: str`` - deve ser uma string, por padrão do tipo `None`
|
101
|
+
``display_message`` - deve ser um booleano, por padrão `False`
|
95
102
|
|
96
103
|
Retorno:
|
97
104
|
----------
|
@@ -149,7 +156,7 @@ class File():
|
|
149
156
|
|
150
157
|
def flag_create(self,
|
151
158
|
name_file: str = 'running.flag',
|
152
|
-
path_to_create: str = None,
|
159
|
+
path_to_create: str | None = None,
|
153
160
|
display_message: bool = True) -> None:
|
154
161
|
"""
|
155
162
|
Cria um arquivo de sinalização indicando que o robô está em execução.
|
@@ -172,7 +179,7 @@ class File():
|
|
172
179
|
|
173
180
|
def flag_delete(self,
|
174
181
|
name_file: str = 'running.flag',
|
175
|
-
path_to_delete: str = None,
|
182
|
+
path_to_delete: str | None = None,
|
176
183
|
display_message: bool = True,) -> None:
|
177
184
|
|
178
185
|
"""
|
@@ -241,7 +248,7 @@ class File():
|
|
241
248
|
# Process
|
242
249
|
try:
|
243
250
|
for dir in dir_to_count:
|
244
|
-
for
|
251
|
+
for _, _, files in os.walk(dir):
|
245
252
|
for file in files:
|
246
253
|
if type_extension == '*' or file.endswith(f'.{type_extension}'):
|
247
254
|
result['qt'] += 1
|