rpa-suite 1.1.9__tar.gz → 1.3.0__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.1.9 → rpa_suite-1.3.0}/PKG-INFO +20 -8
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/README.md +18 -6
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/clock/exec_at.py +13 -7
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/date/date.py +11 -11
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/email/sender_smtp.py +26 -9
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/file/__create_ss_dir.py +1 -1
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/file/counter.py +10 -9
- rpa_suite-1.3.0/rpa_suite/file/file_flag.py +103 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/file/screen_shot.py +10 -6
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/file/temp_dir.py +11 -8
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/log/__create_log_dir.py +6 -4
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/log/_functions_logger.py +7 -7
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/log/_logger.py +2 -2
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/log/functions_logger_uru.py +14 -14
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/log/logger_uru.py +2 -2
- rpa_suite-1.3.0/rpa_suite/regex/pattern_in_text.py +58 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/suite.py +5 -2
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/validate/mail_validator.py +6 -2
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/validate/string_validator.py +5 -12
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite.egg-info/PKG-INFO +20 -8
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite.egg-info/SOURCES.txt +2 -1
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/setup.py +2 -2
- rpa_suite-1.1.9/rpa_suite/regex/list_from_text.py +0 -47
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/LICENSE +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/__init__.py +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/clock/__init__.py +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/clock/scheduler.py +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/clock/waiter.py +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/date/__init__.py +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/email/__init__.py +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/file/__init__.py +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/log/__init__.py +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/log/_variables.py +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/log/_variables_uru.py +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/log/log_decorator.py +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/log/printer.py +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/regex/__init__.py +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite/validate/__init__.py +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite.egg-info/dependency_links.txt +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite.egg-info/requires.txt +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/rpa_suite.egg-info/top_level.txt +0 -0
- {rpa_suite-1.1.9 → rpa_suite-1.3.0}/setup.cfg +0 -0
@@ -1,11 +1,11 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: rpa_suite
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.3.0
|
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
|
7
7
|
License: MIT
|
8
|
-
Keywords: basic-tools,email-tools,email-validation,file-tools,simple-functions,rpa-tools,rpa-functions,Tools,Rpa,Automation,RPA,Automação,Python,Ferramentas de RPA,Automação de Processos,Biblioteca Python para RPA
|
8
|
+
Keywords: basic-tools,email-tools,email-validation,file-tools,simple-functions,rpa-tools,rpa-functions,Tools,Rpa,Automation,RPA,Automação,Python,Ferramentas de RPA,Automação de Processos,Biblioteca Python para RPA,Bot,Robô,Ferramentas de automação
|
9
9
|
Classifier: Development Status :: 3 - Alpha
|
10
10
|
Classifier: Programming Language :: Python :: 3.11
|
11
11
|
Classifier: Programming Language :: Python :: 3.12
|
@@ -23,7 +23,7 @@ Requires-Dist: colorama
|
|
23
23
|
Requires-Dist: email_validator
|
24
24
|
Requires-Dist: colorlog
|
25
25
|
|
26
|
-

|
27
27
|
|
28
28
|
|
29
29
|
<h1 align="left">
|
@@ -129,7 +129,7 @@ No setup do nosso projeto já estão inclusas as dependências, só será necess
|
|
129
129
|
- colorlog
|
130
130
|
|
131
131
|
[!IMPORTANT]
|
132
|
-
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
|
132
|
+
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.
|
133
133
|
|
134
134
|
## Estrutura do módulo
|
135
135
|
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
|
@@ -145,25 +145,37 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
|
|
145
145
|
- **counter** - Funções para contagem de arquivos
|
146
146
|
- **temp_dir** - Funções para diretórios temporários
|
147
147
|
- **screen_shot** - Função para criar diretório e arquivo de print com nome do diretório, arquivo e delay personalizáveis
|
148
|
+
- **file_flag** - Funções para criar e deletar arquivo utilizado como flag de execução, tendo path e nome do arquivo já automatico porem personalizavel para se adequar ao seu projeto
|
148
149
|
- **log**
|
149
150
|
- **logger_uru** - Instanciador de stream e handlefile que cria na pasta raiz do arquivo chamador pasta de log e seta o stream para as funções de log
|
150
151
|
- **functions_logger_uru** - Funções de log parecida com os prints personalizados, setadas e personalizadas para todos log levels usado pelo ´logger_uru´, já escreve no arquivo setado além de gerar o print no terminal
|
151
152
|
- **printer** - Funções de print personalizados (alerta, erro, sucesso, informativo)
|
152
153
|
- **regex**
|
153
|
-
- **
|
154
|
+
- **pattern_in_text** - Função para otimizar o uso mais comum de regex buscando padrões em um texto
|
154
155
|
- **validate**
|
155
156
|
- **mail_validator** - Função para validar lista de emails, devolvendo a lista com emails validos a partir da lista original
|
156
|
-
- **string_validator** - Função que valida presença de letras, palavras, e
|
157
|
+
- **string_validator** - Função que valida presença de letras, palavras, e textos e possibilita contar as ocorrencias em uma string
|
157
158
|
|
158
159
|
## Release
|
159
|
-
Versão: **Beta 1.
|
160
|
+
Versão: **Beta 1.3.0**
|
160
161
|
|
161
162
|
Lançamento: *20/02/2024*
|
162
|
-
Última atualização: *
|
163
|
+
Última atualização: *05/11/2024*
|
163
164
|
|
164
165
|
Status: Em desenvolvimento.
|
165
166
|
|
166
167
|
|
168
|
+
### Notas da ultima atualização
|
169
|
+
|
170
|
+
- Correções de bugs em diversas funções relacionadas a tempo: *exec_at_hour* , *wait_for_exec* , *exec_and_wait*
|
171
|
+
- Correções de bugs com tempo superior a 10 minutos nas funções de data: *get_hms* e *get_dma*
|
172
|
+
- Função **get_dma** atualizada e **renomeada** para **get_dmy** para manter o padrão em ingles
|
173
|
+
- Função *send_email* atualizada para suportar autenticação *SSL* ou *TLS* via argumentos recebidos nos parametros
|
174
|
+
- Adicionado parametro de *"display_message"* para o usuario poder ativar ou desativar as mensagens de console em cada função
|
175
|
+
- Correção de bug na função *"count_files"* para realizar de maneira correta a soma de todos arquivos nos diretórios
|
176
|
+
- Funções de regex e busca em textos por strings e palavras atualizadas
|
177
|
+
- Implementado nova função para arquivo de flag para execuções, no submodulo file, as funções são: *"file_flag_create"* e *"file_flag_delete"*
|
178
|
+
|
167
179
|
## Mais Sobre
|
168
180
|
|
169
181
|
Para mais informações, visite nosso projeto no Github ou PyPi:
|
@@ -1,4 +1,4 @@
|
|
1
|
-

|
2
2
|
|
3
3
|
|
4
4
|
<h1 align="left">
|
@@ -104,7 +104,7 @@ No setup do nosso projeto já estão inclusas as dependências, só será necess
|
|
104
104
|
- colorlog
|
105
105
|
|
106
106
|
[!IMPORTANT]
|
107
|
-
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
|
107
|
+
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.
|
108
108
|
|
109
109
|
## Estrutura do módulo
|
110
110
|
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
|
@@ -120,25 +120,37 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
|
|
120
120
|
- **counter** - Funções para contagem de arquivos
|
121
121
|
- **temp_dir** - Funções para diretórios temporários
|
122
122
|
- **screen_shot** - Função para criar diretório e arquivo de print com nome do diretório, arquivo e delay personalizáveis
|
123
|
+
- **file_flag** - Funções para criar e deletar arquivo utilizado como flag de execução, tendo path e nome do arquivo já automatico porem personalizavel para se adequar ao seu projeto
|
123
124
|
- **log**
|
124
125
|
- **logger_uru** - Instanciador de stream e handlefile que cria na pasta raiz do arquivo chamador pasta de log e seta o stream para as funções de log
|
125
126
|
- **functions_logger_uru** - Funções de log parecida com os prints personalizados, setadas e personalizadas para todos log levels usado pelo ´logger_uru´, já escreve no arquivo setado além de gerar o print no terminal
|
126
127
|
- **printer** - Funções de print personalizados (alerta, erro, sucesso, informativo)
|
127
128
|
- **regex**
|
128
|
-
- **
|
129
|
+
- **pattern_in_text** - Função para otimizar o uso mais comum de regex buscando padrões em um texto
|
129
130
|
- **validate**
|
130
131
|
- **mail_validator** - Função para validar lista de emails, devolvendo a lista com emails validos a partir da lista original
|
131
|
-
- **string_validator** - Função que valida presença de letras, palavras, e
|
132
|
+
- **string_validator** - Função que valida presença de letras, palavras, e textos e possibilita contar as ocorrencias em uma string
|
132
133
|
|
133
134
|
## Release
|
134
|
-
Versão: **Beta 1.
|
135
|
+
Versão: **Beta 1.3.0**
|
135
136
|
|
136
137
|
Lançamento: *20/02/2024*
|
137
|
-
Última atualização: *
|
138
|
+
Última atualização: *05/11/2024*
|
138
139
|
|
139
140
|
Status: Em desenvolvimento.
|
140
141
|
|
141
142
|
|
143
|
+
### Notas da ultima atualização
|
144
|
+
|
145
|
+
- Correções de bugs em diversas funções relacionadas a tempo: *exec_at_hour* , *wait_for_exec* , *exec_and_wait*
|
146
|
+
- Correções de bugs com tempo superior a 10 minutos nas funções de data: *get_hms* e *get_dma*
|
147
|
+
- Função **get_dma** atualizada e **renomeada** para **get_dmy** para manter o padrão em ingles
|
148
|
+
- Função *send_email* atualizada para suportar autenticação *SSL* ou *TLS* via argumentos recebidos nos parametros
|
149
|
+
- Adicionado parametro de *"display_message"* para o usuario poder ativar ou desativar as mensagens de console em cada função
|
150
|
+
- Correção de bug na função *"count_files"* para realizar de maneira correta a soma de todos arquivos nos diretórios
|
151
|
+
- Funções de regex e busca em textos por strings e palavras atualizadas
|
152
|
+
- Implementado nova função para arquivo de flag para execuções, no submodulo file, as funções são: *"file_flag_create"* e *"file_flag_delete"*
|
153
|
+
|
142
154
|
## Mais Sobre
|
143
155
|
|
144
156
|
Para mais informações, visite nosso projeto no Github ou PyPi:
|
@@ -6,11 +6,11 @@ from datetime import datetime as dt
|
|
6
6
|
from rpa_suite.log.printer import error_print, success_print
|
7
7
|
|
8
8
|
def exec_at_hour(
|
9
|
+
time_waiting: int,
|
9
10
|
hour_to_exec: str,
|
10
11
|
fn_to_exec: Callable[..., Any],
|
11
12
|
*args,
|
12
|
-
**kwargs,
|
13
|
-
) -> dict[str, bool]:
|
13
|
+
**kwargs) -> dict[str, bool]:
|
14
14
|
|
15
15
|
"""
|
16
16
|
Timed function, executes the function at the specified time, by ``default`` it executes at runtime, optionally you can choose the time for execution.
|
@@ -71,8 +71,8 @@ def exec_at_hour(
|
|
71
71
|
# Preprocessing
|
72
72
|
run = True
|
73
73
|
now = dt.now()
|
74
|
-
hours = str(now.hour) if now.hour
|
75
|
-
minutes = str(now.minute) if now.minute
|
74
|
+
hours = str(now.hour) if now.hour >= 10 else f"0{now.hour}"
|
75
|
+
minutes = str(now.minute) if now.minute >= 10 else f"0{now.minute}"
|
76
76
|
moment_now = f'{hours}:{minutes}'
|
77
77
|
|
78
78
|
if hour_to_exec == None:
|
@@ -112,10 +112,16 @@ def exec_at_hour(
|
|
112
112
|
error_print(f'An error occurred that prevented the function from executing: {fn_to_exec.__name__} correctly. Error: {str(e)}')
|
113
113
|
break
|
114
114
|
else:
|
115
|
-
|
115
|
+
|
116
|
+
# interval to new validate hour
|
117
|
+
if time_waiting:
|
118
|
+
time.sleep(time_waiting)
|
119
|
+
else:
|
120
|
+
time.sleep(9)
|
121
|
+
|
116
122
|
now = dt.now()
|
117
|
-
hours = str(now.hour) if now.hour
|
118
|
-
minutes = str(now.minute) if now.minute
|
123
|
+
hours = str(now.hour) if now.hour >= 10 else f"0{now.hour}"
|
124
|
+
minutes = str(now.minute) if now.minute >= 10 else f"0{now.minute}"
|
119
125
|
moment_now = f'{hours}:{minutes}'
|
120
126
|
|
121
127
|
return result
|
@@ -9,7 +9,7 @@ from rpa_suite.log.printer import error_print
|
|
9
9
|
def get_hms() -> Tuple[Op[str], Op[str], Op[str]]:
|
10
10
|
|
11
11
|
"""
|
12
|
-
Function to return
|
12
|
+
Function to return Hour, Minute and Second. The return is in the form of a tuple with strings being able to store and use the values individually.
|
13
13
|
|
14
14
|
Treatment:
|
15
15
|
----------
|
@@ -51,9 +51,9 @@ def get_hms() -> Tuple[Op[str], Op[str], Op[str]]:
|
|
51
51
|
|
52
52
|
# Preprocessing
|
53
53
|
now = dt.datetime.now()
|
54
|
-
hours: str = str(now.hour) if now.hour
|
55
|
-
minutes: str = str(now.minute) if now.minute
|
56
|
-
seconds: str = str(now.second) if now.second
|
54
|
+
hours: str = str(now.hour) if now.hour >= 10 else f"0{now.hour}"
|
55
|
+
minutes: str = str(now.minute) if now.minute >= 10 else f"0{now.minute}"
|
56
|
+
seconds: str = str(now.second) if now.second >= 10 else f"0{now.second}"
|
57
57
|
|
58
58
|
# Process
|
59
59
|
try:
|
@@ -73,9 +73,9 @@ def get_hms() -> Tuple[Op[str], Op[str], Op[str]]:
|
|
73
73
|
return None, None, None
|
74
74
|
|
75
75
|
|
76
|
-
def
|
76
|
+
def get_dmy() -> Tuple[Op[str], Op[str], Op[str]]:
|
77
77
|
"""
|
78
|
-
Function to return
|
78
|
+
Function to return Day, Month and Year. The return is in the form of a tuple with strings being able to store and use the values individually.
|
79
79
|
|
80
80
|
Return:
|
81
81
|
----------
|
@@ -84,7 +84,7 @@ def get_dma() -> Tuple[Op[str], Op[str], Op[str]]:
|
|
84
84
|
|
85
85
|
Example:
|
86
86
|
---------
|
87
|
-
>>> day, month, year =
|
87
|
+
>>> day, month, year = get_dmy() \n
|
88
88
|
* NOTE: Note that it is possible to destructure the return to store simultaneously.
|
89
89
|
|
90
90
|
Description: pt-br
|
@@ -98,7 +98,7 @@ def get_dma() -> Tuple[Op[str], Op[str], Op[str]]:
|
|
98
98
|
|
99
99
|
Exemplo:
|
100
100
|
---------
|
101
|
-
>>> dia, mes, ano =
|
101
|
+
>>> dia, mes, ano = get_dmy() \n
|
102
102
|
* OBS.: Note que é possivel desestruturar o retorno para armazenar de forma simultânea.
|
103
103
|
"""
|
104
104
|
|
@@ -112,9 +112,9 @@ def get_dma() -> Tuple[Op[str], Op[str], Op[str]]:
|
|
112
112
|
|
113
113
|
# Process
|
114
114
|
try:
|
115
|
-
day_got: str = str(now.day) if now.day
|
116
|
-
month_got: str = str(now.month) if now.month
|
117
|
-
year_got: str = str(now.year) if now.year
|
115
|
+
day_got: str = str(now.day) if now.day >= 10 else f"0{now.day}"
|
116
|
+
month_got: str = str(now.month) if now.month >= 10 else f"0{now.month}"
|
117
|
+
year_got: str = str(now.year) if now.year >= 10 else f"0{now.year}"
|
118
118
|
|
119
119
|
return day_got, month_got, year_got
|
120
120
|
|
@@ -19,7 +19,8 @@ def send_email(
|
|
19
19
|
attachments: list[str] = None,
|
20
20
|
type_content: str = 'html',
|
21
21
|
smtp_server: str = 'smtp.office365.com',
|
22
|
-
smtp_port: int = 587
|
22
|
+
smtp_port: int = 587,
|
23
|
+
authentication_tls: bool = True,
|
23
24
|
) -> dict:
|
24
25
|
|
25
26
|
"""
|
@@ -37,7 +38,8 @@ def send_email(
|
|
37
38
|
``attachments: list[str]`` - list with path of attachments if any. (default None).
|
38
39
|
``type_content: str`` - type of message content can be 'plain' or 'html' (default 'html').
|
39
40
|
``smtp_server: str`` - server to be used to connect with the email account (default 'smtp.office365.com')
|
40
|
-
``smtp_port: int`` - port to be used on this server (default 587)
|
41
|
+
``smtp_port: int`` - port to be used on this server (default 587 - TLS), commum use 465 for SSL authentication
|
42
|
+
``authentication_tls: bool`` - authentication method (default True), if False use SSL authentication
|
41
43
|
|
42
44
|
Return:
|
43
45
|
----------
|
@@ -68,7 +70,8 @@ def send_email(
|
|
68
70
|
``attachments: list[str]`` - lista com caminho de anexos se houver. (default None).
|
69
71
|
``type_content: str`` - tipo de conteudo da mensagem pode ser 'plain' ou 'html' (default 'html').
|
70
72
|
``smtp_server: str`` - servidor a ser utilizado para conectar com a conta de email (default 'smtp.office365.com')
|
71
|
-
``smtp_port: int`` - porta a ser utilizada nesse servidor (default 587)
|
73
|
+
``smtp_port: int`` - porta a ser utilizada nesse servidor (default 587 - TLS), comum usar 465 para autenticação por SSL
|
74
|
+
``authentication_tls: bool`` - metódo de autenticação (default True), caso Falso usa autenticação por SSL
|
72
75
|
|
73
76
|
Retorno:
|
74
77
|
----------
|
@@ -141,11 +144,22 @@ def send_email(
|
|
141
144
|
|
142
145
|
# SMTP server config
|
143
146
|
try:
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
147
|
+
|
148
|
+
# authentication TLS True -> Using TLS
|
149
|
+
if authentication_tls:
|
150
|
+
|
151
|
+
server_by_smtp = smtplib.SMTP(smtp_server, smtp_port)
|
152
|
+
server_by_smtp.starttls()
|
153
|
+
server_by_smtp.login(email_from, pass_from)
|
154
|
+
email_content = msg.as_string()
|
155
|
+
|
156
|
+
else: # authentication TLS False -> Using SSL
|
157
|
+
|
158
|
+
# connect SMTP server using SSL
|
159
|
+
server_by_smtp = smtplib.SMTP_SSL(smtp_server, smtp_port)
|
160
|
+
server_by_smtp.login(email_from, pass_from)
|
161
|
+
email_content = msg.as_string()
|
162
|
+
|
149
163
|
# Treats the email list before trying to send, keeping only valid emails
|
150
164
|
try:
|
151
165
|
for emails in email_to:
|
@@ -170,7 +184,7 @@ def send_email(
|
|
170
184
|
except smtplib.SMTPException as e:
|
171
185
|
error_print(f"The email: {email} don't sent, caused by error: {str(e)}")
|
172
186
|
|
173
|
-
server_by_smtp.quit()
|
187
|
+
#server_by_smtp.quit()
|
174
188
|
result['success'] = True
|
175
189
|
success_print(f'Email(s) Sent!')
|
176
190
|
|
@@ -178,6 +192,9 @@ def send_email(
|
|
178
192
|
except smtplib.SMTPException as e:
|
179
193
|
result['success'] = False
|
180
194
|
error_print(f'Error while trying sent Email: {str(e)}')
|
195
|
+
|
196
|
+
finally:
|
197
|
+
server_by_smtp.quit()
|
181
198
|
|
182
199
|
# Postprocessing
|
183
200
|
result['valid_mails'] = email_valido
|
@@ -8,7 +8,7 @@ from rpa_suite.log.printer import error_print, alert_print, success_print
|
|
8
8
|
def __create_ss_dir(path_to_create: str = 'default', name_ss_dir: str='screenshots') -> dict[str, Union[bool, str, None]]:
|
9
9
|
|
10
10
|
"""
|
11
|
-
Function responsible for creating a
|
11
|
+
Function responsible for creating a ScreenShots directory to work with your screenshot files. \n
|
12
12
|
|
13
13
|
Parameters:
|
14
14
|
----------
|
@@ -6,8 +6,9 @@ from rpa_suite.log.printer import error_print, success_print
|
|
6
6
|
|
7
7
|
|
8
8
|
def count_files(
|
9
|
-
dir_to_count: List[str],
|
10
|
-
type_extension: str = '*'
|
9
|
+
dir_to_count: List[str] = ['.'],
|
10
|
+
type_extension: str = '*',
|
11
|
+
display_message: bool = False,
|
11
12
|
) -> Dict[str, Union[bool, int]]:
|
12
13
|
|
13
14
|
"""
|
@@ -40,25 +41,25 @@ def count_files(
|
|
40
41
|
* 'qt': int - numero que representa a quantidade de arquivos que foram contados
|
41
42
|
"""
|
42
43
|
|
44
|
+
|
43
45
|
# Local Variables
|
44
46
|
result: dict = {
|
45
|
-
'success':
|
46
|
-
'qt':
|
47
|
+
'success': False,
|
48
|
+
'qt': 0
|
47
49
|
}
|
48
50
|
|
49
|
-
# Preprocessing
|
50
|
-
result['success'] = False
|
51
|
-
result['qt'] = 0
|
52
51
|
|
53
52
|
# Process
|
54
53
|
try:
|
55
54
|
for dir in dir_to_count:
|
56
55
|
for current_dir, sub_dir, files in os.walk(dir):
|
57
56
|
for file in files:
|
58
|
-
if file.endswith(f'.{type_extension}'):
|
57
|
+
if type_extension == '*' or file.endswith(f'.{type_extension}'):
|
59
58
|
result['qt'] += 1
|
60
59
|
result['success'] = True
|
61
|
-
|
60
|
+
|
61
|
+
if display_message:
|
62
|
+
success_print(f'Function: {count_files.__name__} counted {result["qt"]} files.')
|
62
63
|
|
63
64
|
except Exception as e:
|
64
65
|
result['success'] = False
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# /file_flag.py
|
2
|
+
|
3
|
+
import os, time
|
4
|
+
from rpa_suite import suite as rpa
|
5
|
+
|
6
|
+
|
7
|
+
def file_flag_create(display_message: bool = True, path_to_create: str = None, name_file: str = 'running.flag') -> None:
|
8
|
+
"""
|
9
|
+
Function responsible for create a file flag on root directory by default. Path, name file and display message was optional. \n
|
10
|
+
|
11
|
+
Parameters:
|
12
|
+
----------
|
13
|
+
``display_message: bool`` - should be boolean, True prints message on console.
|
14
|
+
``path_to_create: str`` - should be a string, by default use root dir with "os.getcwd()".
|
15
|
+
``name_file: str`` - should be a string, by default "running.flag".
|
16
|
+
|
17
|
+
Return:
|
18
|
+
----------
|
19
|
+
>>> type:bool
|
20
|
+
* 'bool' - represents the result of performance this action
|
21
|
+
|
22
|
+
Description: pt-br
|
23
|
+
----------
|
24
|
+
Função responsável por criar um arquivo de flag na raiz do projeto por padrão. O diretório, o nome do arquivo e a possibilidade de imprimir no console a mensagem de sucesso, são opcionais.
|
25
|
+
|
26
|
+
Parâmetros:
|
27
|
+
----------
|
28
|
+
``display_message: bool`` - deve ser booleano, True para o caso de imprimir no console a mensagem de resultado.
|
29
|
+
``path_to_create: str`` - deve ser string, por padrão usa como raiz do projeto o comando "os.getcwd()".
|
30
|
+
``name_file: str`` - deve ser string, por padrão "running.flag".
|
31
|
+
|
32
|
+
Retorno:
|
33
|
+
----------
|
34
|
+
>>> tipo: bool
|
35
|
+
* 'bool' - representa o resultado performado da ação
|
36
|
+
"""
|
37
|
+
|
38
|
+
try:
|
39
|
+
if path_to_create == None:
|
40
|
+
path_origin: str = os.getcwd()
|
41
|
+
full_path_with_name = fr'{path_origin}/{name_file}'
|
42
|
+
else:
|
43
|
+
full_path_with_name = fr'{path_to_create}/{name_file}'
|
44
|
+
|
45
|
+
with open(full_path_with_name, 'w', encoding='utf-8') as file:
|
46
|
+
file.write('[T-BOT Crédit Simulation] running in realtime, waiting finish to new execution')
|
47
|
+
|
48
|
+
if display_message: rpa.success_print("Flag file created.")
|
49
|
+
return True
|
50
|
+
|
51
|
+
except Exception as e:
|
52
|
+
rpa.error_print(f'Erro na função file_scheduling_create: {str(e)}')
|
53
|
+
return False
|
54
|
+
|
55
|
+
|
56
|
+
def file_flag_delete(display_message: bool = True, path_to_delete: str = None, name_file: str = 'running.flag') -> None:
|
57
|
+
"""
|
58
|
+
Function responsible for delete a file flag on root directory by default. Path, name file and display message was optional. \n
|
59
|
+
|
60
|
+
Parameters:
|
61
|
+
----------
|
62
|
+
``display_message: bool`` - should be boolean, True prints message on console.
|
63
|
+
``path_to_delete: str`` - should be a string, by default use root dir with "os.getcwd()".
|
64
|
+
``name_file: str`` - should be a string, by default "running.flag".
|
65
|
+
|
66
|
+
Return:
|
67
|
+
----------
|
68
|
+
>>> type:bool
|
69
|
+
* 'bool' - represents the result of performance this action
|
70
|
+
|
71
|
+
Description: pt-br
|
72
|
+
----------
|
73
|
+
Função responsável por deletar um arquivo de flag na raiz do projeto por padrão. O diretório, o nome do arquivo e a possibilidade de imprimir no console a mensagem de sucesso, são opcionais.
|
74
|
+
|
75
|
+
Parâmetros:
|
76
|
+
----------
|
77
|
+
``display_message: bool`` - deve ser booleano, True para o caso de imprimir no console a mensagem de resultado.
|
78
|
+
``path_to_delete: str`` - deve ser string, por padrão usa como raiz do projeto o comando "os.getcwd()".
|
79
|
+
``name_file: str`` - deve ser string, por padrão "running.flag".
|
80
|
+
|
81
|
+
Retorno:
|
82
|
+
----------
|
83
|
+
>>> tipo: bool
|
84
|
+
* 'bool' - representa o resultado performado da ação
|
85
|
+
"""
|
86
|
+
|
87
|
+
try:
|
88
|
+
|
89
|
+
if path_to_delete == None:
|
90
|
+
path_origin: str = os.getcwd()
|
91
|
+
full_path_with_name = fr'{path_origin}/{name_file}'
|
92
|
+
else:
|
93
|
+
full_path_with_name = fr'{path_to_delete}/{name_file}'
|
94
|
+
|
95
|
+
if os.path.exists(full_path_with_name):
|
96
|
+
os.remove(full_path_with_name)
|
97
|
+
if display_message: print("Flag file deleted.")
|
98
|
+
else:
|
99
|
+
rpa.alert_print("Flag file not found.")
|
100
|
+
|
101
|
+
except Exception as e:
|
102
|
+
rpa.error_print(f'Erro na função file_scheduling_delete: {str(e)}')
|
103
|
+
time.sleep(1)
|
@@ -4,11 +4,11 @@ import os, time
|
|
4
4
|
from datetime import datetime
|
5
5
|
from rpa_suite.log.printer import error_print, success_print
|
6
6
|
from .__create_ss_dir import __create_ss_dir
|
7
|
+
from colorama import Fore
|
7
8
|
|
8
9
|
|
9
10
|
|
10
|
-
|
11
|
-
def screen_shot(path_dir:str = None, file_name: str = 'screenshot', save_with_date: bool = True, delay: int = 1, use_default_path_and_name: bool = True, name_ss_dir:str = None) -> str | None:
|
11
|
+
def screen_shot(path_dir:str = None, file_name: str = 'screenshot', save_with_date: bool = True, delay: int = 1, use_default_path_and_name: bool = True, name_ss_dir:str = None, display_message: bool = False) -> str | None:
|
12
12
|
|
13
13
|
"""
|
14
14
|
Function responsible for create a dir for screenshot, and file screenshot and save this in dir to create, if dir exists save it on original dir. By default uses date on file name. \n
|
@@ -50,7 +50,7 @@ def screen_shot(path_dir:str = None, file_name: str = 'screenshot', save_with_da
|
|
50
50
|
import pyscreeze
|
51
51
|
|
52
52
|
except ImportError:
|
53
|
-
raise ImportError("
|
53
|
+
raise ImportError(f"\nThe libraries ‘pyautogui’ and ‘Pillow’ are necessary to use this module. {Fore.YELLOW}Please install them with: ‘pip install pyautogui pillow‘{Fore.WHITE}")
|
54
54
|
|
55
55
|
time.sleep(delay)
|
56
56
|
|
@@ -68,9 +68,10 @@ def screen_shot(path_dir:str = None, file_name: str = 'screenshot', save_with_da
|
|
68
68
|
file_name = f'{file_name}_{datetime.today().strftime("%d_%m_%Y-%H_%M_%S")}.png'
|
69
69
|
path_file_screenshoted = os.path.join(path_dir, file_name)
|
70
70
|
|
71
|
-
success_print(path_file_screenshoted)
|
72
|
-
|
73
71
|
image.save(path_file_screenshoted)
|
72
|
+
if display_message:
|
73
|
+
success_print(path_file_screenshoted)
|
74
|
+
|
74
75
|
return path_file_screenshoted
|
75
76
|
|
76
77
|
else: # not use date on file name
|
@@ -79,9 +80,12 @@ def screen_shot(path_dir:str = None, file_name: str = 'screenshot', save_with_da
|
|
79
80
|
path_file_screenshoted = os.path.join(path_dir, file_name)
|
80
81
|
|
81
82
|
image.save(path_file_screenshoted)
|
83
|
+
if display_message:
|
84
|
+
success_print(path_file_screenshoted)
|
85
|
+
|
82
86
|
return path_file_screenshoted
|
83
87
|
|
84
88
|
except Exception as e:
|
85
89
|
|
86
|
-
error_print(f'
|
90
|
+
error_print(f'Error to execute function:{screen_shot.__name__}! Error: {str(e)}')
|
87
91
|
return None
|
@@ -5,7 +5,7 @@ from typing import Union
|
|
5
5
|
from rpa_suite.log.printer import error_print, alert_print, success_print
|
6
6
|
|
7
7
|
|
8
|
-
def create_temp_dir(path_to_create: str = 'default', name_temp_dir: str='temp') -> dict[str, Union[bool, str, None]]:
|
8
|
+
def create_temp_dir(path_to_create: str = 'default', name_temp_dir: str='temp', display_message: bool = False) -> dict[str, Union[bool, str, None]]:
|
9
9
|
|
10
10
|
"""
|
11
11
|
Function responsible for creating a temporary directory to work with files and etc. \n
|
@@ -62,17 +62,18 @@ def create_temp_dir(path_to_create: str = 'default', name_temp_dir: str='temp')
|
|
62
62
|
result['success'] = True
|
63
63
|
result['path_created'] = fr'{full_path}'
|
64
64
|
|
65
|
-
|
65
|
+
if display_message:
|
66
|
+
success_print(f"Dir:'{full_path}' Created!")
|
66
67
|
|
67
68
|
except FileExistsError:
|
68
69
|
result['success'] = False
|
69
70
|
result['path_created'] = None
|
70
|
-
alert_print(f"
|
71
|
+
alert_print(f"Dir:'{full_path}' already exists.")
|
71
72
|
|
72
73
|
except PermissionError:
|
73
74
|
result['success'] = False
|
74
75
|
result['path_created'] = None
|
75
|
-
alert_print(f"
|
76
|
+
alert_print(f"Permission Denied: Not Able to create dir:'{full_path}'.")
|
76
77
|
|
77
78
|
except Exception as e:
|
78
79
|
result['success'] = False
|
@@ -83,7 +84,7 @@ def create_temp_dir(path_to_create: str = 'default', name_temp_dir: str='temp')
|
|
83
84
|
return result
|
84
85
|
|
85
86
|
|
86
|
-
def delete_temp_dir(path_to_delete: str = 'default', name_temp_dir: str='temp', delete_files: bool = False) -> dict[str, Union[bool, str, None]]:
|
87
|
+
def delete_temp_dir(path_to_delete: str = 'default', name_temp_dir: str='temp', delete_files: bool = False, display_message: bool = False) -> dict[str, Union[bool, str, None]]:
|
87
88
|
|
88
89
|
"""
|
89
90
|
Function responsible for deleting a temporary directory. \n
|
@@ -153,16 +154,18 @@ def delete_temp_dir(path_to_delete: str = 'default', name_temp_dir: str='temp',
|
|
153
154
|
result['success'] = True
|
154
155
|
result['path_deleted'] = fr'{full_path}'
|
155
156
|
|
156
|
-
|
157
|
+
if display_message:
|
158
|
+
success_print(f"Dir:'{full_path}' Deleted!")
|
159
|
+
|
157
160
|
else:
|
158
161
|
result['success'] = False
|
159
162
|
result['path_deleted'] = None
|
160
|
-
alert_print(f"
|
163
|
+
alert_print(f"Dir:'{full_path}' Don't exists.")
|
161
164
|
|
162
165
|
except PermissionError:
|
163
166
|
result['success'] = False
|
164
167
|
result['path_deleted'] = None
|
165
|
-
alert_print(f"
|
168
|
+
alert_print(f"Permission Denied: Not Able to delete dir: '{full_path}'.")
|
166
169
|
|
167
170
|
except Exception as e:
|
168
171
|
result['success'] = False
|
@@ -38,13 +38,15 @@ def _create_log_dir(path_to_create: str = 'default', name_log_dir: str='logs') -
|
|
38
38
|
* 'success': bool - representa se ação foi realizada com sucesso
|
39
39
|
* 'path_created': str - path do diretório que foi criado no processo
|
40
40
|
"""
|
41
|
-
|
41
|
+
|
42
|
+
|
42
43
|
# Local Variables
|
43
44
|
result: dict = {
|
44
45
|
'success': bool,
|
45
46
|
'path_created': str,
|
46
47
|
}
|
47
|
-
|
48
|
+
|
49
|
+
|
48
50
|
try:
|
49
51
|
# by 'default', defines path to local script execution path
|
50
52
|
if path_to_create == 'default':
|
@@ -62,7 +64,7 @@ def _create_log_dir(path_to_create: str = 'default', name_log_dir: str='logs') -
|
|
62
64
|
result['success'] = True
|
63
65
|
result['path_created'] = fr'{full_path}'
|
64
66
|
|
65
|
-
success_print(f"
|
67
|
+
success_print(f"Dir:'{full_path}' created!")
|
66
68
|
|
67
69
|
except FileExistsError:
|
68
70
|
result['success'] = False
|
@@ -72,7 +74,7 @@ def _create_log_dir(path_to_create: str = 'default', name_log_dir: str='logs') -
|
|
72
74
|
except PermissionError:
|
73
75
|
result['success'] = False
|
74
76
|
result['path_created'] = None
|
75
|
-
alert_print(f"
|
77
|
+
alert_print(f"Permission Denied: Not Able to create: '{full_path}'.")
|
76
78
|
|
77
79
|
except Exception as e:
|
78
80
|
result['success'] = False
|
@@ -17,7 +17,7 @@ def log_start_run_debug(msg_start_loggin: str) -> None: # represent start applic
|
|
17
17
|
success_print(f'{msg_start_loggin}')
|
18
18
|
|
19
19
|
except Exception as e:
|
20
|
-
error_print(f'
|
20
|
+
error_print(f'Error to execute function:{log_start_run_debug.__name__}! Error: {str(e)}')
|
21
21
|
|
22
22
|
|
23
23
|
def log_debug(msg) -> None:
|
@@ -30,7 +30,7 @@ def log_debug(msg) -> None:
|
|
30
30
|
logging.debug(msg)
|
31
31
|
|
32
32
|
except Exception as e:
|
33
|
-
error_print(f'
|
33
|
+
error_print(f'Error to execute function:{log_debug.__name__}! Error: {str(e)}')
|
34
34
|
|
35
35
|
def log_info(msg) -> None:
|
36
36
|
|
@@ -42,7 +42,7 @@ def log_info(msg) -> None:
|
|
42
42
|
logging.info(msg)
|
43
43
|
|
44
44
|
except Exception as e:
|
45
|
-
error_print(f'
|
45
|
+
error_print(f'Error to execute function:{log_debug.__name__}! Error: {str(e)}')
|
46
46
|
|
47
47
|
def log_info(msg) -> None:
|
48
48
|
|
@@ -54,7 +54,7 @@ def log_info(msg) -> None:
|
|
54
54
|
logging.info(msg)
|
55
55
|
|
56
56
|
except Exception as e:
|
57
|
-
error_print(f'
|
57
|
+
error_print(f'Error to execute function:{log_info.__name__}! Error: {str(e)}')
|
58
58
|
|
59
59
|
|
60
60
|
def log_warning(msg) -> None:
|
@@ -67,7 +67,7 @@ def log_warning(msg) -> None:
|
|
67
67
|
logging.warning(msg)
|
68
68
|
|
69
69
|
except Exception as e:
|
70
|
-
error_print(f'
|
70
|
+
error_print(f'Error to execute function:{log_warning.__name__}! Error: {str(e)}')
|
71
71
|
|
72
72
|
|
73
73
|
def log_error(msg) -> None:
|
@@ -80,7 +80,7 @@ def log_error(msg) -> None:
|
|
80
80
|
logging.error(msg)
|
81
81
|
|
82
82
|
except Exception as e:
|
83
|
-
error_print(f'
|
83
|
+
error_print(f'Error to execute function:{log_error.__name__}! Error: {str(e)}')
|
84
84
|
|
85
85
|
|
86
86
|
def log_critical(msg) -> None:
|
@@ -93,4 +93,4 @@ def log_critical(msg) -> None:
|
|
93
93
|
logging.critical(msg)
|
94
94
|
|
95
95
|
except Exception as e:
|
96
|
-
error_print(f'
|
96
|
+
error_print(f'Error to execute function:{log_critical.__name__}! Error: {str(e)}')
|
@@ -29,7 +29,7 @@ class Filters(Filter):
|
|
29
29
|
input()"""
|
30
30
|
for word in string_words:
|
31
31
|
if word in record.msg:
|
32
|
-
record.msg = 'Log
|
32
|
+
record.msg = 'Log with filtered words!'
|
33
33
|
return True
|
34
34
|
|
35
35
|
return True
|
@@ -109,5 +109,5 @@ def config_logger(name_app:str = 'Logger', path_dir:str = None, name_log_dir:str
|
|
109
109
|
|
110
110
|
except Exception as e:
|
111
111
|
|
112
|
-
error_print(f'
|
112
|
+
error_print(f'Error to execute function:{config_logger.__name__}! Error: {str(e)}.')
|
113
113
|
return None
|
@@ -19,7 +19,7 @@ def log_start_run_debug(msg_start_loggin: str) -> None: # represent start applic
|
|
19
19
|
|
20
20
|
except Exception as e:
|
21
21
|
|
22
|
-
error_print(f'
|
22
|
+
error_print(f'To use log_start_run_debug you need instance file_handler using file "logger_uru" on one file in your project! Error: {str(e)}')
|
23
23
|
|
24
24
|
try:
|
25
25
|
try:
|
@@ -28,7 +28,7 @@ def log_start_run_debug(msg_start_loggin: str) -> None: # represent start applic
|
|
28
28
|
f.write('\n')
|
29
29
|
|
30
30
|
except Exception as e:
|
31
|
-
alert_print(f'
|
31
|
+
alert_print(f"Don't able to break_row for initial log!")
|
32
32
|
|
33
33
|
# logger.debug(f'{msg_start_loggin}')
|
34
34
|
frame = inspect.currentframe().f_back
|
@@ -46,7 +46,7 @@ def log_start_run_debug(msg_start_loggin: str) -> None: # represent start applic
|
|
46
46
|
logger.bind(filename=filename, lineno=lineno).debug(f'{msg_start_loggin}')
|
47
47
|
|
48
48
|
except Exception as e:
|
49
|
-
error_print(f'
|
49
|
+
error_print(f'Error to execute function:{log_start_run_debug.__name__}! Error: {str(e)}')
|
50
50
|
|
51
51
|
|
52
52
|
def log_debug(msg) -> None:
|
@@ -59,19 +59,19 @@ def log_debug(msg) -> None:
|
|
59
59
|
frame = inspect.currentframe().f_back
|
60
60
|
full_path_filename = frame.f_code.co_filename
|
61
61
|
|
62
|
-
#
|
62
|
+
# Obtem o nome do arquivo e o nome da pasta
|
63
63
|
filename = os.path.basename(full_path_filename)
|
64
64
|
foldername = os.path.basename(os.path.dirname(full_path_filename))
|
65
65
|
|
66
|
-
#
|
66
|
+
# Combina o nome da pasta e o nome do arquivo
|
67
67
|
filename = os.path.join(foldername, filename)
|
68
68
|
lineno = frame.f_lineno
|
69
69
|
|
70
|
-
#
|
70
|
+
# Vincula o nome do arquivo e a linha à mensagem de log
|
71
71
|
logger.bind(filename=filename, lineno=lineno).debug(msg)
|
72
72
|
|
73
73
|
except Exception as e:
|
74
|
-
error_print(f'
|
74
|
+
error_print(f'Error to execute function:{log_debug.__name__}! Error: {str(e)}')
|
75
75
|
|
76
76
|
def log_info(msg) -> None:
|
77
77
|
|
@@ -83,19 +83,19 @@ def log_info(msg) -> None:
|
|
83
83
|
frame = inspect.currentframe().f_back
|
84
84
|
full_path_filename = frame.f_code.co_filename
|
85
85
|
|
86
|
-
#
|
86
|
+
# Obtem o nome do arquivo e o nome da pasta
|
87
87
|
filename = os.path.basename(full_path_filename)
|
88
88
|
foldername = os.path.basename(os.path.dirname(full_path_filename))
|
89
89
|
|
90
|
-
#
|
90
|
+
# Combina o nome da pasta e o nome do arquivo
|
91
91
|
filename = os.path.join(foldername, filename)
|
92
92
|
lineno = frame.f_lineno
|
93
93
|
|
94
|
-
#
|
94
|
+
# Vincula o nome do arquivo e a linha à mensagem de log
|
95
95
|
logger.bind(filename=filename, lineno=lineno).info(msg)
|
96
96
|
|
97
97
|
except Exception as e:
|
98
|
-
error_print(f'
|
98
|
+
error_print(f'Error to execute function:{log_info.__name__}! Error: {str(e)}')
|
99
99
|
|
100
100
|
def log_warning(msg) -> None:
|
101
101
|
|
@@ -119,7 +119,7 @@ def log_warning(msg) -> None:
|
|
119
119
|
logger.bind(filename=filename, lineno=lineno).warning(msg)
|
120
120
|
|
121
121
|
except Exception as e:
|
122
|
-
error_print(f'
|
122
|
+
error_print(f'Error to execute function:{log_warning.__name__}! Error: {str(e)}')
|
123
123
|
|
124
124
|
|
125
125
|
def log_error(msg) -> None:
|
@@ -144,7 +144,7 @@ def log_error(msg) -> None:
|
|
144
144
|
logger.bind(filename=filename, lineno=lineno).error(msg)
|
145
145
|
|
146
146
|
except Exception as e:
|
147
|
-
error_print(f'
|
147
|
+
error_print(f'Error to execute function:{log_error.__name__}! Error: {str(e)}')
|
148
148
|
|
149
149
|
|
150
150
|
def log_critical(msg) -> None:
|
@@ -169,4 +169,4 @@ def log_critical(msg) -> None:
|
|
169
169
|
logger.bind(filename=filename, lineno=lineno).critical(msg)
|
170
170
|
|
171
171
|
except Exception as e:
|
172
|
-
error_print(f'
|
172
|
+
error_print(f'Error to execute function:{log_critical.__name__}! Error: {str(e)}')
|
@@ -19,7 +19,7 @@ class Filters:
|
|
19
19
|
|
20
20
|
for word in string_words:
|
21
21
|
if word in record["message"]:
|
22
|
-
record["message"] = 'Log
|
22
|
+
record["message"] = 'Log with filtered words!'
|
23
23
|
return True
|
24
24
|
|
25
25
|
return True
|
@@ -106,5 +106,5 @@ def config_logger(path_dir:str = None, name_log_dir:str = None, name_file_log: s
|
|
106
106
|
|
107
107
|
except Exception as e:
|
108
108
|
|
109
|
-
error_print(f'
|
109
|
+
error_print(f'Error to execute function:{config_logger.__name__}! Error: {str(e)}.')
|
110
110
|
return None
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# /pattern_in_text.py
|
2
|
+
|
3
|
+
import re
|
4
|
+
from rpa_suite.log.printer import error_print, success_print
|
5
|
+
|
6
|
+
|
7
|
+
def check_pattern_in_text(origin_text: str,
|
8
|
+
pattern_to_search: str,
|
9
|
+
case_sensitive: bool = True,
|
10
|
+
display_message: bool = False) -> bool:
|
11
|
+
|
12
|
+
"""
|
13
|
+
Function responsible for searching in a string ``origin_text`` a pattern ``pattern_to_search`` and returning True if the pattern is found, otherwise False. ``case_sensitive`` used for exact cases or cases with diferencce upper and lower cases
|
14
|
+
|
15
|
+
Return:
|
16
|
+
----------
|
17
|
+
A boolean indicating whether the pattern was found in the text.
|
18
|
+
|
19
|
+
Description: pt-br
|
20
|
+
----------
|
21
|
+
Função responsável por buscar em um texto de leitura humana uma string ``origin_text`` por um padrão ``pattern_to_search`` e retornar True se o padrão for encontrado, caso contrário, False. ``case_sensitive`` usado para casos exatos ou casos com diferença entre caixa alta e baixa nos caracteres.
|
22
|
+
|
23
|
+
Retorno:
|
24
|
+
----------
|
25
|
+
Um booleano indicando se o padrão foi encontrado no texto.
|
26
|
+
"""
|
27
|
+
|
28
|
+
try:
|
29
|
+
|
30
|
+
if case_sensitive:
|
31
|
+
|
32
|
+
# Check if the pattern is found in the text
|
33
|
+
if re.search(pattern_to_search, origin_text):
|
34
|
+
if display_message: success_print(f'Pattern found successfully!')
|
35
|
+
return True
|
36
|
+
|
37
|
+
else:
|
38
|
+
if display_message: success_print(f'Pattern not found.')
|
39
|
+
return False
|
40
|
+
else:
|
41
|
+
|
42
|
+
# normalize text to search without case sensitive
|
43
|
+
origin_text = origin_text.lower()
|
44
|
+
pattern_to_search = pattern_to_search.lower()
|
45
|
+
|
46
|
+
# Check if the pattern is found in the text
|
47
|
+
if re.search(pattern_to_search, origin_text):
|
48
|
+
if display_message: success_print(f'Pattern found successfully!')
|
49
|
+
return True
|
50
|
+
|
51
|
+
else:
|
52
|
+
if display_message: success_print(f'Pattern not found.')
|
53
|
+
return False
|
54
|
+
|
55
|
+
except Exception as e:
|
56
|
+
|
57
|
+
error_print(f"Error when trying to check pattern in text. Error: {str(e)}")
|
58
|
+
return False
|
@@ -44,6 +44,7 @@ from .email.sender_smtp import send_email
|
|
44
44
|
from .file.counter import count_files
|
45
45
|
from .file.temp_dir import create_temp_dir, delete_temp_dir
|
46
46
|
from .file.screen_shot import screen_shot
|
47
|
+
from .file.file_flag import file_flag_create, file_flag_delete
|
47
48
|
|
48
49
|
"""MODULE LOG"""
|
49
50
|
# from .log.loggin import logging_decorator
|
@@ -54,7 +55,7 @@ from .log.functions_logger_uru import log_start_run_debug, log_debug, log_info,
|
|
54
55
|
|
55
56
|
|
56
57
|
"""MODULE REGEX"""
|
57
|
-
from .regex.
|
58
|
+
from .regex.pattern_in_text import check_pattern_in_text
|
58
59
|
|
59
60
|
|
60
61
|
"""MODULE VALIDATE"""
|
@@ -105,6 +106,8 @@ class Rpa_suite():
|
|
105
106
|
create_temp_dir = create_temp_dir
|
106
107
|
delete_temp_dir = delete_temp_dir
|
107
108
|
screen_shot = screen_shot
|
109
|
+
file_flag_create = file_flag_create
|
110
|
+
file_flag_delete = file_flag_delete
|
108
111
|
#clear_temp_dir = clear_temp_dir
|
109
112
|
|
110
113
|
# log - printer
|
@@ -127,7 +130,7 @@ class Rpa_suite():
|
|
127
130
|
log_critical = log_critical
|
128
131
|
|
129
132
|
# regex
|
130
|
-
|
133
|
+
check_pattern_in_text = check_pattern_in_text
|
131
134
|
|
132
135
|
# validate
|
133
136
|
valid_emails = valid_emails
|
@@ -4,7 +4,8 @@ import email_validator
|
|
4
4
|
from rpa_suite.log.printer import error_print, success_print
|
5
5
|
|
6
6
|
def valid_emails(
|
7
|
-
email_list: list[str]
|
7
|
+
email_list: list[str],
|
8
|
+
display_message: bool = False,
|
8
9
|
) -> dict:
|
9
10
|
|
10
11
|
"""
|
@@ -71,7 +72,10 @@ def valid_emails(
|
|
71
72
|
|
72
73
|
except email_validator.EmailNotValidError:
|
73
74
|
invalid_emails.append(email)
|
74
|
-
|
75
|
+
|
76
|
+
if display_message:
|
77
|
+
success_print(f'Function:{valid_emails.__name__} executed!')
|
78
|
+
|
75
79
|
except Exception as e:
|
76
80
|
error_print(f'Error when trying to validate email list: {str(e)}')
|
77
81
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
from rpa_suite.log.printer import success_print, error_print
|
4
4
|
|
5
|
-
def
|
5
|
+
def search_str_in(
|
6
6
|
origin_text: str,
|
7
7
|
searched_word: str,
|
8
8
|
case_sensitivy: bool = True,
|
@@ -91,6 +91,7 @@ def search_in(
|
|
91
91
|
words_lowercase = [word.lower() for word in origin_words]
|
92
92
|
searched_word = searched_word.lower()
|
93
93
|
result['is_found'] = searched_word in words_lowercase
|
94
|
+
|
94
95
|
except Exception as e:
|
95
96
|
return error_print(f'Unable to complete the search: {searched_word}. Error: {str(e)}')
|
96
97
|
|
@@ -102,19 +103,11 @@ def search_in(
|
|
102
103
|
origin_text_lower: str = origin_text.lower()
|
103
104
|
searched_word_lower: str = searched_word.lower()
|
104
105
|
result['is_found'] = origin_text_lower.__contains__(searched_word_lower)
|
106
|
+
|
105
107
|
except Exception as e:
|
106
108
|
return error_print(f'Unable to complete the search: {searched_word}. Error: {str(e)}')
|
107
|
-
|
108
|
-
|
109
|
-
pass
|
110
|
-
"""try:
|
111
|
-
if case_sensitivy:
|
112
|
-
print(f'metodo para buscar com sensitivy...')
|
113
|
-
else:
|
114
|
-
print(f'metodo para buscar sem sensitive...')
|
115
|
-
except Exception as e:
|
116
|
-
return print(f'Não foi possivel concluir a busca de: {searched_word}. Error: {str(e)}')"""
|
117
|
-
|
109
|
+
|
110
|
+
|
118
111
|
except Exception as e:
|
119
112
|
return error_print(f'Unable to search for: {searched_word}. Error: {str(e)}')
|
120
113
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: rpa-suite
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.3.0
|
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
|
7
7
|
License: MIT
|
8
|
-
Keywords: basic-tools,email-tools,email-validation,file-tools,simple-functions,rpa-tools,rpa-functions,Tools,Rpa,Automation,RPA,Automação,Python,Ferramentas de RPA,Automação de Processos,Biblioteca Python para RPA
|
8
|
+
Keywords: basic-tools,email-tools,email-validation,file-tools,simple-functions,rpa-tools,rpa-functions,Tools,Rpa,Automation,RPA,Automação,Python,Ferramentas de RPA,Automação de Processos,Biblioteca Python para RPA,Bot,Robô,Ferramentas de automação
|
9
9
|
Classifier: Development Status :: 3 - Alpha
|
10
10
|
Classifier: Programming Language :: Python :: 3.11
|
11
11
|
Classifier: Programming Language :: Python :: 3.12
|
@@ -23,7 +23,7 @@ Requires-Dist: colorama
|
|
23
23
|
Requires-Dist: email_validator
|
24
24
|
Requires-Dist: colorlog
|
25
25
|
|
26
|
-

|
27
27
|
|
28
28
|
|
29
29
|
<h1 align="left">
|
@@ -129,7 +129,7 @@ No setup do nosso projeto já estão inclusas as dependências, só será necess
|
|
129
129
|
- colorlog
|
130
130
|
|
131
131
|
[!IMPORTANT]
|
132
|
-
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
|
132
|
+
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.
|
133
133
|
|
134
134
|
## Estrutura do módulo
|
135
135
|
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
|
@@ -145,25 +145,37 @@ O módulo principal do rpa-suite é dividido em categorias. Cada categoria cont
|
|
145
145
|
- **counter** - Funções para contagem de arquivos
|
146
146
|
- **temp_dir** - Funções para diretórios temporários
|
147
147
|
- **screen_shot** - Função para criar diretório e arquivo de print com nome do diretório, arquivo e delay personalizáveis
|
148
|
+
- **file_flag** - Funções para criar e deletar arquivo utilizado como flag de execução, tendo path e nome do arquivo já automatico porem personalizavel para se adequar ao seu projeto
|
148
149
|
- **log**
|
149
150
|
- **logger_uru** - Instanciador de stream e handlefile que cria na pasta raiz do arquivo chamador pasta de log e seta o stream para as funções de log
|
150
151
|
- **functions_logger_uru** - Funções de log parecida com os prints personalizados, setadas e personalizadas para todos log levels usado pelo ´logger_uru´, já escreve no arquivo setado além de gerar o print no terminal
|
151
152
|
- **printer** - Funções de print personalizados (alerta, erro, sucesso, informativo)
|
152
153
|
- **regex**
|
153
|
-
- **
|
154
|
+
- **pattern_in_text** - Função para otimizar o uso mais comum de regex buscando padrões em um texto
|
154
155
|
- **validate**
|
155
156
|
- **mail_validator** - Função para validar lista de emails, devolvendo a lista com emails validos a partir da lista original
|
156
|
-
- **string_validator** - Função que valida presença de letras, palavras, e
|
157
|
+
- **string_validator** - Função que valida presença de letras, palavras, e textos e possibilita contar as ocorrencias em uma string
|
157
158
|
|
158
159
|
## Release
|
159
|
-
Versão: **Beta 1.
|
160
|
+
Versão: **Beta 1.3.0**
|
160
161
|
|
161
162
|
Lançamento: *20/02/2024*
|
162
|
-
Última atualização: *
|
163
|
+
Última atualização: *05/11/2024*
|
163
164
|
|
164
165
|
Status: Em desenvolvimento.
|
165
166
|
|
166
167
|
|
168
|
+
### Notas da ultima atualização
|
169
|
+
|
170
|
+
- Correções de bugs em diversas funções relacionadas a tempo: *exec_at_hour* , *wait_for_exec* , *exec_and_wait*
|
171
|
+
- Correções de bugs com tempo superior a 10 minutos nas funções de data: *get_hms* e *get_dma*
|
172
|
+
- Função **get_dma** atualizada e **renomeada** para **get_dmy** para manter o padrão em ingles
|
173
|
+
- Função *send_email* atualizada para suportar autenticação *SSL* ou *TLS* via argumentos recebidos nos parametros
|
174
|
+
- Adicionado parametro de *"display_message"* para o usuario poder ativar ou desativar as mensagens de console em cada função
|
175
|
+
- Correção de bug na função *"count_files"* para realizar de maneira correta a soma de todos arquivos nos diretórios
|
176
|
+
- Funções de regex e busca em textos por strings e palavras atualizadas
|
177
|
+
- Implementado nova função para arquivo de flag para execuções, no submodulo file, as funções são: *"file_flag_create"* e *"file_flag_delete"*
|
178
|
+
|
167
179
|
## Mais Sobre
|
168
180
|
|
169
181
|
Para mais informações, visite nosso projeto no Github ou PyPi:
|
@@ -19,6 +19,7 @@ rpa_suite/email/sender_smtp.py
|
|
19
19
|
rpa_suite/file/__create_ss_dir.py
|
20
20
|
rpa_suite/file/__init__.py
|
21
21
|
rpa_suite/file/counter.py
|
22
|
+
rpa_suite/file/file_flag.py
|
22
23
|
rpa_suite/file/screen_shot.py
|
23
24
|
rpa_suite/file/temp_dir.py
|
24
25
|
rpa_suite/log/__create_log_dir.py
|
@@ -32,7 +33,7 @@ rpa_suite/log/log_decorator.py
|
|
32
33
|
rpa_suite/log/logger_uru.py
|
33
34
|
rpa_suite/log/printer.py
|
34
35
|
rpa_suite/regex/__init__.py
|
35
|
-
rpa_suite/regex/
|
36
|
+
rpa_suite/regex/pattern_in_text.py
|
36
37
|
rpa_suite/validate/__init__.py
|
37
38
|
rpa_suite/validate/mail_validator.py
|
38
39
|
rpa_suite/validate/string_validator.py
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name='rpa_suite',
|
5
|
-
version='1.
|
5
|
+
version='1.3.0',
|
6
6
|
packages=find_packages(),
|
7
7
|
description='Conjunto de ferramentas essenciais para Automação RPA com Python, que facilitam o dia a dia de desenvolvimento.',
|
8
8
|
long_description_content_type='text/markdown',
|
@@ -22,6 +22,6 @@ setup(
|
|
22
22
|
'Topic :: Scientific/Engineering :: Artificial Intelligence',
|
23
23
|
'Topic :: Software Development :: Libraries :: Python Modules'
|
24
24
|
],
|
25
|
-
keywords='basic-tools, email-tools, email-validation, file-tools, simple-functions, rpa-tools, rpa-functions, Tools, Rpa, Automation, RPA, Automação, Python, Ferramentas de RPA, Automação de Processos, Biblioteca Python para RPA',
|
25
|
+
keywords='basic-tools, email-tools, email-validation, file-tools, simple-functions, rpa-tools, rpa-functions, Tools, Rpa, Automation, RPA, Automação, Python, Ferramentas de RPA, Automação de Processos, Biblioteca Python para RPA, Bot, Robô, Ferramentas de automação',
|
26
26
|
install_requires=['loguru', 'colorama', 'email_validator', 'colorlog'],
|
27
27
|
)
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# /list_from_text.py
|
2
|
-
|
3
|
-
import re
|
4
|
-
from typing import Any
|
5
|
-
from rpa_suite.log.printer import error_print, success_print
|
6
|
-
|
7
|
-
def create_list_using_regex(origin_text: str, division_pattern: str) -> list[str] | Any:
|
8
|
-
|
9
|
-
"""
|
10
|
-
Function responsible for searching in a string ``origin_text`` a pattern ``division_pattern`` and dividing the original text into substrings generating a list of strings, also does the cleaning and treatment to keep the list with the original strings, but divided
|
11
|
-
|
12
|
-
Return:
|
13
|
-
----------
|
14
|
-
A list of strings divided by the pattern used in the argument passed as a parameter.
|
15
|
-
|
16
|
-
Description: pt-br
|
17
|
-
----------
|
18
|
-
Função responsável por buscar em um texto de leitura humana uma string ``origin_text`` por um padrão ``division_pattern`` e dividir o texto original em substrings gerando uma lista de strings, também faz a limpeza e tratamento para manter a lista com as strings originais, porem dividas
|
19
|
-
|
20
|
-
Retorno:
|
21
|
-
----------
|
22
|
-
Uma lista de strings dividas pelo padrão utilizada no argumento passado como parametro.
|
23
|
-
"""
|
24
|
-
|
25
|
-
try:
|
26
|
-
# creates a delimiter and uses it to split the string based on the pattern
|
27
|
-
text_with_delim = re.sub(division_pattern, r'\1<DELIMITADOR>', origin_text)
|
28
|
-
messages = text_with_delim.split('<DELIMITADOR>')
|
29
|
-
|
30
|
-
# Remove the last string if it is empty or has excess spaces
|
31
|
-
if messages[-1] == '':
|
32
|
-
messages = messages[:-1]
|
33
|
-
|
34
|
-
# Returns only messages with content.
|
35
|
-
messages = [msg for msg in messages if msg.strip()]
|
36
|
-
|
37
|
-
# Removes the delimiter \n both left and right from each element of the list
|
38
|
-
messages_striped = [msg.strip() for i, msg in enumerate(messages)]
|
39
|
-
messages_lstriped = [msg.lstrip() for msg in messages_striped]
|
40
|
-
|
41
|
-
# Removes the delimiter that has been placed between punctuation within the same pattern.
|
42
|
-
messages_final = [msg.replace('\n', ' ') for msg in messages_lstriped]
|
43
|
-
success_print(f'List generated successfully!')
|
44
|
-
return messages_final
|
45
|
-
|
46
|
-
except Exception as e:
|
47
|
-
error_print(f"Error when trying to create list using pattern-match (regex). Error: {str(e)}")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|