rpa-suite 1.3.4__py3-none-any.whl → 1.3.6__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.
Files changed (48) hide show
  1. rpa_suite/__init__.py +4 -1
  2. rpa_suite/core/__init__.py +1 -0
  3. rpa_suite/core/clock.py +271 -0
  4. rpa_suite/core/date.py +138 -0
  5. rpa_suite/core/dir.py +182 -0
  6. rpa_suite/core/email.py +343 -0
  7. rpa_suite/core/file.py +209 -0
  8. rpa_suite/core/log.py +304 -0
  9. rpa_suite/core/print.py +197 -0
  10. rpa_suite/core/regex.py +62 -0
  11. rpa_suite/core/validate.py +220 -0
  12. rpa_suite/{log → functions}/__create_log_dir.py +5 -7
  13. rpa_suite/{file → functions}/__create_ss_dir.py +2 -2
  14. rpa_suite/functions/__init__.py +1 -0
  15. rpa_suite/{log → functions}/_functions_logger.py +8 -8
  16. rpa_suite/{log → functions}/_logger.py +3 -3
  17. rpa_suite/suite.py +238 -148
  18. {rpa_suite-1.3.4.dist-info → rpa_suite-1.3.6.dist-info}/METADATA +7 -4
  19. rpa_suite-1.3.6.dist-info/RECORD +25 -0
  20. rpa_suite/clock/__init__.py +0 -1
  21. rpa_suite/clock/exec_at.py +0 -133
  22. rpa_suite/clock/scheduler.py +0 -38
  23. rpa_suite/clock/waiter.py +0 -139
  24. rpa_suite/date/__init__.py +0 -1
  25. rpa_suite/date/date.py +0 -124
  26. rpa_suite/email/__init__.py +0 -1
  27. rpa_suite/email/sender_smtp.py +0 -203
  28. rpa_suite/file/__init__.py +0 -1
  29. rpa_suite/file/counter.py +0 -69
  30. rpa_suite/file/file_flag.py +0 -103
  31. rpa_suite/file/screen_shot.py +0 -91
  32. rpa_suite/file/temp_dir.py +0 -176
  33. rpa_suite/log/__init__.py +0 -1
  34. rpa_suite/log/functions_logger_uru.py +0 -172
  35. rpa_suite/log/log_decorator.py +0 -37
  36. rpa_suite/log/logger_uru.py +0 -110
  37. rpa_suite/regex/__init__.py +0 -1
  38. rpa_suite/regex/pattern_in_text.py +0 -58
  39. rpa_suite/validate/__init__.py +0 -1
  40. rpa_suite/validate/mail_validator.py +0 -93
  41. rpa_suite/validate/string_validator.py +0 -120
  42. rpa_suite-1.3.4.dist-info/RECORD +0 -36
  43. /rpa_suite/{log/printer.py → functions/_printer.py} +0 -0
  44. /rpa_suite/{log → functions}/_variables.py +0 -0
  45. /rpa_suite/{log → functions}/_variables_uru.py +0 -0
  46. {rpa_suite-1.3.4.dist-info → rpa_suite-1.3.6.dist-info}/WHEEL +0 -0
  47. {rpa_suite-1.3.4.dist-info → rpa_suite-1.3.6.dist-info}/licenses/LICENSE +0 -0
  48. {rpa_suite-1.3.4.dist-info → rpa_suite-1.3.6.dist-info}/top_level.txt +0 -0
rpa_suite/clock/waiter.py DELETED
@@ -1,139 +0,0 @@
1
- # /waiter.py
2
-
3
- import time
4
- from typing import Callable, Any
5
- from rpa_suite.log.printer import error_print, success_print
6
-
7
- def wait_for_exec(
8
- wait_time: int,
9
- fn_to_exec: Callable[..., Any],
10
- *args,
11
- **kwargs
12
- ) -> dict[str, bool]:
13
-
14
- """
15
- Timer function, wait for a value in ``seconds`` to execute the function of the argument.
16
-
17
- Parameters:
18
- ----------
19
- `wait_time: int` - (seconds) represents the time that should wait before executing the function passed as an argument.
20
-
21
- ``fn_to_exec: function`` - (function) to be called after the waiting time, if there are parameters in this function they can be passed as next arguments of this function in ``*args`` and ``**kwargs``
22
-
23
- Return:
24
- ----------
25
- >>> type:dict
26
- * 'success': bool - represents if the action was performed successfully
27
-
28
- Example:
29
- ---------
30
- 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 wait `30 seconds` to execute this function, so:
31
- >>> wait_for_exec(30, sum, 10, 5) -> 15 \n
32
- * 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.
33
-
34
- Description: pt-br
35
- ----------
36
- Função temporizadora, aguardar um valor em ``segundos`` para executar a função do argumento.
37
-
38
- Parametros:
39
- ----------
40
- `wait_time: int` - (segundos) representa o tempo que deve aguardar antes de executar a função passada como argumento.
41
-
42
- ``fn_to_exec: function`` - (função) a ser chamada depois do tempo aguardado, se houver parametros nessa função podem ser passados como próximos argumentos desta função em ``*args`` e ``**kwargs``
43
-
44
- Retorno:
45
- ----------
46
- >>> type:dict
47
- * 'success': bool - representa se ação foi realizada com sucesso
48
-
49
- Exemplo:
50
- ---------
51
- Temos uma função de soma no seguinte formato ``soma(a, b) -> return x``, onde ``x`` é o resultado da soma. Queremos aguardar `30 segundos` para executar essa função, logo:
52
- >>> wait_for_exec(30, soma, 10, 5) -> 15 \n
53
- * OBS.: `wait_for_exec` recebe como primeiro argumento o tempo a aguardar (seg), depois a função `soma` e por fim os argumentos que a função ira usar.
54
- """
55
-
56
- # Local Variables
57
- result: dict = {
58
- 'success': bool
59
- }
60
-
61
- # Process
62
- try:
63
- time.sleep(wait_time)
64
- fn_to_exec(*args, **kwargs)
65
- result['success'] = True
66
- success_print(f'Function: {wait_for_exec.__name__} executed the function: {fn_to_exec.__name__}.')
67
-
68
- except Exception as e:
69
- result['success'] = False
70
- error_print(f'Error while trying to wait to execute the function: {fn_to_exec.__name__} \nMessage: {str(e)}')
71
-
72
- return result
73
-
74
- def exec_and_wait(
75
- wait_time: int,
76
- fn_to_exec: Callable[..., Any],
77
- *args,
78
- **kwargs
79
- ) -> dict[str, bool]:
80
-
81
- """
82
- Timer function, executes a function and waits for the time in ``seconds``
83
-
84
- Parameters:
85
- ----------
86
- `wait_time: int` - (seconds) represents the time that should wait after executing the requested function
87
-
88
- ``fn_to_exec: function`` - (function) to be called before the time to wait, if there are parameters in this function they can be passed as an argument after the function, being: ``*args`` and ``**kwargs``
89
-
90
- Return:
91
- ----------
92
- >>> type:dict
93
- * 'success': bool - represents if the action was performed successfully
94
-
95
- Example:
96
- ---------
97
- 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:
98
- >>> wait_for_exec(30, sum, 10, 5) -> 15 \n
99
- * 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.
100
-
101
- Description: pt-br
102
- ----------
103
- Função temporizadora, executa uma função e aguarda o tempo em ``segundos``
104
-
105
- Parametros:
106
- ----------
107
- `wait_time: int` - (segundos) representa o tempo que deve aguardar após executar a função solicitada
108
-
109
- ``fn_to_exec: function`` - (função) a ser chamada antes do tempo para aguardar, se houver parametros nessa função podem ser passados como argumento depois da função, sendo: ``*args`` e ``**kwargs``
110
-
111
- Retorno:
112
- ----------
113
- >>> type:dict
114
- * 'success': bool - representa se ação foi realizada com sucesso
115
-
116
- Exemplo:
117
- ---------
118
- Temos uma função de soma no seguinte formato ``soma(a, b) -> return x``, onde ``x`` é o resultado da soma. Queremos executar a soma e então aguardar `30 segundos` para continuar o código principal:
119
- >>> wait_for_exec(30, soma, 10, 5) -> 15 \n
120
- * OBS.: `wait_for_exec` recebe como primeiro argumento o tempo a aguardar (seg), depois a função `soma` e por fim os argumentos que a função ira usar.
121
- """
122
-
123
- # Local Variables
124
- result: dict = {
125
- 'success': bool
126
- }
127
-
128
- # Process
129
- try:
130
- fn_to_exec(*args, **kwargs)
131
- time.sleep(wait_time)
132
- result['success'] = True
133
- success_print(f'Function: {wait_for_exec.__name__} executed the function: {fn_to_exec.__name__}.')
134
-
135
- except Exception as e:
136
- result['success'] = False
137
- error_print(f'Error while trying to wait to execute the function: {fn_to_exec.__name__} \nMessage: {str(e)}')
138
-
139
- return result
@@ -1 +0,0 @@
1
- # /__init__.py
rpa_suite/date/date.py DELETED
@@ -1,124 +0,0 @@
1
- # /date.py
2
-
3
- import datetime as dt
4
- from typing import Optional as Op
5
- from typing import Tuple
6
- from rpa_suite.log.printer import error_print
7
-
8
-
9
- def get_hms() -> Tuple[Op[str], Op[str], Op[str]]:
10
-
11
- """
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
-
14
- Treatment:
15
- ----------
16
- The function already does the treatment for values below 10 always keeping 2 decimal places in all results, the individual values are always in string format
17
-
18
- Return:
19
- ----------
20
- >>> type:tuple
21
- * tuple('hh', 'mm', 'ss') - tuple with the values of hour, minute and second being able to be stored individually, the values are in string
22
-
23
- Example:
24
- ---------
25
- >>> hour, minute, second = get_hms() \n
26
- * NOTE: Note that it is possible to destructure the return to store simultaneously.
27
-
28
- Description: pt-br
29
- ----------
30
- Função para retornar hora, minuto e segundo. O retorno é em forma de tupla com strings podendo armazenar e usar os valores de forma individual.
31
-
32
- Tratamento:
33
- ----------
34
- A função já faz o tratamento para valores abaixo de 10 mantendo sempre 2 casas decimais em todos resultados, os valores individuais são sempre em formato string
35
-
36
- Retorno:
37
- ----------
38
- >>> type:tuple
39
- * tuple('hh', 'mm', 'ss') - tupla com os valores de hora, minuto e segundo podendo ser armazenados individualmente, os valores são em string
40
-
41
- Exemplo:
42
- ---------
43
- >>> hora, minuto, segundo = get_hms() \n
44
- * OBS.: Note que é possivel desestruturar o retorno para armazenar de forma simultânea.
45
- """
46
-
47
- # Local Variables
48
- hours: str
49
- minutes: str
50
- seconds: str
51
-
52
- # Preprocessing
53
- now = dt.datetime.now()
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
-
58
- # Process
59
- try:
60
- if len(hours) == 3 or len(minutes) == 3 or len(seconds) == 3:
61
- if len(seconds) == 3:
62
- seconds[1:]
63
- elif len(minutes) == 3:
64
- minutes[1:]
65
- elif len(hours) == 3:
66
- hours[1:]
67
-
68
- return hours, minutes, seconds
69
-
70
- except Exception as e:
71
-
72
- error_print(f'Unable to capture the time. Error: {str(e)}')
73
- return None, None, None
74
-
75
-
76
- def get_dmy() -> Tuple[Op[str], Op[str], Op[str]]:
77
- """
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
-
80
- Return:
81
- ----------
82
- >>> type:tuple
83
- * tuple('dd', 'mm', 'yy') - tuple with the values of day, month and year being able to be stored individually
84
-
85
- Example:
86
- ---------
87
- >>> day, month, year = get_dmy() \n
88
- * NOTE: Note that it is possible to destructure the return to store simultaneously.
89
-
90
- Description: pt-br
91
- ----------
92
- Função para retornar dia, mes e ano. O retorno é em forma de tupla com strings podendo armazenar e usar os valores de forma individual.
93
-
94
- Retorno:
95
- ----------
96
- >>> type:tuple
97
- * tuple('dd', 'mm', 'yy') - tupla com os valores de dia, mes e ano podendo ser armazenados individualmente
98
-
99
- Exemplo:
100
- ---------
101
- >>> dia, mes, ano = get_dmy() \n
102
- * OBS.: Note que é possivel desestruturar o retorno para armazenar de forma simultânea.
103
- """
104
-
105
- # Local Variables
106
- day_got: str
107
- month_got: str
108
- year_got: str
109
-
110
- # Preprocessing
111
- now = dt.datetime.now()
112
-
113
- # Process
114
- try:
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
-
119
- return day_got, month_got, year_got
120
-
121
- except Exception as e:
122
-
123
- error_print(f'Unable to capture the time. Error: {str(e)}')
124
- return None, None, None
@@ -1 +0,0 @@
1
- # /__init__.py
@@ -1,203 +0,0 @@
1
- # /sender_smtp.py
2
-
3
- import smtplib, os
4
- from email.mime.image import MIMEImage
5
- from email.mime.multipart import MIMEMultipart
6
- from email.mime.text import MIMEText
7
- from email.mime.base import MIMEBase
8
- from email import encoders
9
- from rpa_suite.log.printer import alert_print, error_print, success_print
10
- from rpa_suite.validate.mail_validator import email_validator
11
-
12
- def send_email(
13
- email_from: str,
14
- pass_from: str,
15
- email_to: list[str],
16
- subject_title: str,
17
- body_message: str,
18
- image_footer: str = None,
19
- attachments: list[str] = None,
20
- type_content: str = 'html',
21
- smtp_server: str = 'smtp.office365.com',
22
- smtp_port: int = 587,
23
- authentication_tls: bool = True,
24
- ) -> dict:
25
-
26
- """
27
- Function responsible for sending emails ``(SMTP)``, accepts ``list of recipients`` and possibility
28
- of ``attaching files``. \n
29
-
30
- Parameters:
31
- ----------
32
- ``email_from: str`` - email from who will send the email.
33
- ``pass_from: str`` - password of the account used, advised to isolate the password elsewhere.
34
- ``email_to: list[str]`` - list of emails to which the emails will be sent.
35
- ``subject_title: str`` - email title.
36
- ``body_message: str``- body message of the email.
37
- ``image_footer: str`` - image footer of body message of the email.
38
- ``attachments: list[str]`` - list with path of attachments if any. (default None).
39
- ``type_content: str`` - type of message content can be 'plain' or 'html' (default 'html').
40
- ``smtp_server: str`` - server to be used to connect with the email account (default 'smtp.office365.com')
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
43
-
44
- Return:
45
- ----------
46
- >>> type:dict
47
- a dictionary with all information that may be necessary about the emails.
48
- Respectively being:
49
- * 'success': bool - if there was at least one successful shipment
50
- * 'all_mails': list - list of all emails parameterized for sending
51
- * 'valid_mails': list - list of all valid emails for sending
52
- * 'invalid_mails': list - list of all invalid emails for sending
53
- * 'qt_mails_sent': int - effective quantity that was sent
54
- * 'attchament': bool - if there are attachments
55
- * 'qt_attach': int - how many attachments were inserted
56
-
57
- Description: pt-br
58
- ----------
59
- Função responsavel por enviar emails ``(SMTP)``, aceita ``lista de destinatários`` e possibilidade
60
- de ``anexar arquivos``. \n
61
-
62
- Parametros:
63
- ----------
64
- ``email_from: str`` - email de quem ira enviar o email.
65
- ``pass_from: str`` - senha da conta utilizada, aconselhado isolar a senha em outro local.
66
- ``email_to: list[str]`` - lista de emails para os quais serão enviados os emails.
67
- ``subject_title: str`` - titulo do email.
68
- ``body_message: str``- mensagem do corpo do email.
69
- ``image_footer: str`` - imagem de rodapé do corpo do email.
70
- ``attachments: list[str]`` - lista com caminho de anexos se houver. (default None).
71
- ``type_content: str`` - tipo de conteudo da mensagem pode ser 'plain' ou 'html' (default 'html').
72
- ``smtp_server: str`` - servidor a ser utilizado para conectar com a conta de email (default 'smtp.office365.com')
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
75
-
76
- Retorno:
77
- ----------
78
- >>> type:dict
79
- um dicionário com todas informações que podem ser necessarias sobre os emails.
80
- Sendo respectivamente:
81
- * 'success': bool - se houve pelo menos um envio com sucesso
82
- * 'all_mails': list - lista de todos emails parametrizados para envio
83
- * 'valid_mails': list - lista de todos emails validos para envio
84
- * 'invalid_mails': list - lista de todos emails invalidos para envio
85
- * 'qt_mails_sent': int - quantidade efetiva que foi realizado envio
86
- * 'attchament': bool - se há anexos
87
- * 'qt_attach': int - quantos anexos foram inseridos
88
- """
89
-
90
- # Local Variables
91
- result: dict = {
92
- 'success': bool,
93
- 'all_mails': list,
94
- 'valid_mails': list,
95
- 'invalid_mails': list,
96
- 'qt_mails_sent': int,
97
- 'attchament': bool,
98
- 'qt_attach': int
99
- }
100
- email_valido = []
101
- email_invalido = []
102
-
103
- # Preprocessing
104
- result['success'] = False
105
- result['qt_mails_sent'] = 0
106
- result['attchament'] = False
107
-
108
- msg = MIMEMultipart()
109
- msg['From'] = email_from
110
- msg['Subject'] = subject_title
111
-
112
- # Email Body Content
113
- msg.attach(MIMEText(body_message, type_content))
114
-
115
- # Add image Footer
116
- if image_footer:
117
- try:
118
- with open(image_footer, 'rb') as img:
119
- msg_image = MIMEImage(img.read())
120
- msg_image.add_header('Content-ID', '<logo>')
121
- # Notice: Content-ID correlact at "cid" on tag <img> at body mail
122
- msg.attach(msg_image)
123
- except FileNotFoundError as e:
124
- alert_print(f'File Not Found! Error: {str(e)}')
125
- except Exception as e:
126
- error_print(f'An Error ocurred, during set image: <{image_footer}> as MIMEImage! Error: {str(e)}')
127
-
128
- # Add Attachment
129
- if attachments:
130
- result['qt_attach'] = 0
131
- result['attchament'] = True
132
- for path_to_attach in attachments:
133
- file_name = os.path.basename(path_to_attach)
134
- attachs = open(path_to_attach, 'rb')
135
- part = MIMEBase('application', 'octet-stream')
136
- part.set_payload((attachs).read())
137
- encoders.encode_base64(part)
138
- part.add_header('Content-Disposition', "attachment; filename= %s" % file_name)
139
- msg.attach(part)
140
- result['qt_attach'] += 1
141
- else:
142
- result['attchament'] = False
143
- result['qt_attach'] = 0
144
-
145
- # SMTP server config
146
- try:
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
-
163
- # Treats the email list before trying to send, keeping only valid emails
164
- try:
165
- for emails in email_to:
166
- try:
167
- v = email_validator.validate_email(emails)
168
- email_valido.append(emails)
169
-
170
- except email_validator.EmailNotValidError:
171
- email_invalido.append(emails)
172
-
173
- except Exception as e:
174
- error_print(f'Error while trying to validate email list: {str(e)}')
175
-
176
- # Attaches the treated email list to perform the sending
177
- msg['To'] = ', '.join(email_valido)
178
- for email in email_valido:
179
- try:
180
- server_by_smtp.sendmail(email_from, email, email_content)
181
- result['qt_mails_sent'] += 1
182
- result['all_mails'] = email_to
183
-
184
- except smtplib.SMTPException as e:
185
- error_print(f"The email: {email} don't sent, caused by error: {str(e)}")
186
-
187
- #server_by_smtp.quit()
188
- result['success'] = True
189
- success_print(f'Email(s) Sent!')
190
-
191
-
192
- except smtplib.SMTPException as e:
193
- result['success'] = False
194
- error_print(f'Error while trying sent Email: {str(e)}')
195
-
196
- finally:
197
- server_by_smtp.quit()
198
-
199
- # Postprocessing
200
- result['valid_mails'] = email_valido
201
- result['invalid_mails'] = email_invalido
202
-
203
- return result
@@ -1 +0,0 @@
1
- # /__init__.py
rpa_suite/file/counter.py DELETED
@@ -1,69 +0,0 @@
1
- # /counter.py
2
-
3
- import os
4
- from typing import Dict, List, Union
5
- from rpa_suite.log.printer import error_print, success_print
6
-
7
-
8
- def count_files(
9
- dir_to_count: List[str] = ['.'],
10
- type_extension: str = '*',
11
- display_message: bool = False,
12
- ) -> Dict[str, Union[bool, int]]:
13
-
14
- """
15
- Function responsible for counting files within a folder, considers subfolders to do the count, searches by file type, being all files by default. \n
16
-
17
- Parameters:
18
- ----------
19
- ``dir_to_count: list`` - should be a list, accepts more than one path to count files.
20
- ``type_extension: str`` - should be a string with the format/extension of the type of file you want to be searched for counting, if empty by default will be used ``*`` which will count all files.
21
-
22
- Return:
23
- ----------
24
- >>> type:dict
25
- * 'success': bool - represents if the action was performed successfully
26
- * 'qt': int - number that represents the quantity of files that were counted
27
-
28
- Description: pt-br
29
- ----------
30
- Função responsavel por fazer a contagem de arquivos dentro de uma pasta, considera subpastas para fazer a contagem, busca por tipo de arquivo, sendo todos arquivos por default. \n
31
-
32
- Parametros:
33
- ----------
34
- ``dir_to_count: list`` - deve ser uma lista, aceita mais de um caminho para contar arquivos.
35
- ``type_extension: str`` - deve ser uma string com o formato/extensão do tipo de arquivo que deseja ser buscado para contagem, se vazio por default sera usado ``*`` que contará todos arquivos.
36
-
37
- Retorno:
38
- ----------
39
- >>> type:dict
40
- * 'success': bool - representa se ação foi realizada com sucesso
41
- * 'qt': int - numero que representa a quantidade de arquivos que foram contados
42
- """
43
-
44
-
45
- # Local Variables
46
- result: dict = {
47
- 'success': False,
48
- 'qt': 0
49
- }
50
-
51
-
52
- # Process
53
- try:
54
- for dir in dir_to_count:
55
- for current_dir, sub_dir, files in os.walk(dir):
56
- for file in files:
57
- if type_extension == '*' or file.endswith(f'.{type_extension}'):
58
- result['qt'] += 1
59
- result['success'] = True
60
-
61
- if display_message:
62
- success_print(f'Function: {count_files.__name__} counted {result["qt"]} files.')
63
-
64
- except Exception as e:
65
- result['success'] = False
66
- error_print(f'Error when trying to count files! Error: {str(e)}')
67
-
68
- finally:
69
- return result
@@ -1,103 +0,0 @@
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)