worker-automate-hub 0.5.8__py3-none-any.whl → 0.5.10__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of worker-automate-hub might be problematic. Click here for more details.
- worker_automate_hub/api/rdp_service.py +38 -0
- worker_automate_hub/tasks/jobs/conexao_rdp.py +2 -2
- worker_automate_hub/tasks/jobs/fechar_conexao_rdp.py +131 -0
- worker_automate_hub/tasks/task_definitions.py +2 -0
- {worker_automate_hub-0.5.8.dist-info → worker_automate_hub-0.5.10.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.5.8.dist-info → worker_automate_hub-0.5.10.dist-info}/RECORD +8 -6
- {worker_automate_hub-0.5.8.dist-info → worker_automate_hub-0.5.10.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.5.8.dist-info → worker_automate_hub-0.5.10.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
import asyncio
|
2
|
+
import aiohttp
|
3
|
+
from rich.console import Console
|
4
|
+
from worker_automate_hub.config.settings import load_env_config
|
5
|
+
from worker_automate_hub.utils.logger import logger
|
6
|
+
|
7
|
+
console = Console()
|
8
|
+
|
9
|
+
async def send_rdp_action(uuid_robo: str, action: str):
|
10
|
+
env_config, _ = load_env_config()
|
11
|
+
|
12
|
+
body = {
|
13
|
+
"uuidRobo": uuid_robo,
|
14
|
+
"action": action
|
15
|
+
}
|
16
|
+
|
17
|
+
headers_basic = {"Authorization": f"Basic {env_config['API_AUTHORIZATION']}"}
|
18
|
+
url = f"{env_config['API_BASE_URL']}/robo/api/manage"
|
19
|
+
|
20
|
+
try:
|
21
|
+
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=True)) as session:
|
22
|
+
async with session.post(url, json=body, headers=headers_basic) as response:
|
23
|
+
if response.status == 200:
|
24
|
+
data = await response.json()
|
25
|
+
logger.info(f"Ação '{action}' enviada com sucesso: {data}")
|
26
|
+
console.print(f"Ação '{action}' enviada com sucesso.", style="bold green")
|
27
|
+
return data
|
28
|
+
else:
|
29
|
+
err_msg = f"Erro ao enviar ação '{action}': {response.status} - {await response.text()}"
|
30
|
+
logger.error(err_msg)
|
31
|
+
console.print(err_msg, style="bold red")
|
32
|
+
return {"error": err_msg}
|
33
|
+
|
34
|
+
except Exception as e:
|
35
|
+
err_msg = f"Erro ao comunicar com o endpoint RDP: {e}"
|
36
|
+
logger.error(err_msg)
|
37
|
+
console.print(err_msg, style="bold red")
|
38
|
+
return {"error": str(e)}
|
@@ -24,7 +24,7 @@ class RDPConnection:
|
|
24
24
|
self.user = task.configEntrada.get("user")
|
25
25
|
self.password = task.configEntrada.get("password")
|
26
26
|
self.processo = task.configEntrada.get("processo")
|
27
|
-
self.uuid_robo = task.configEntrada.get("
|
27
|
+
self.uuid_robo = task.configEntrada.get("uuidRobo")
|
28
28
|
|
29
29
|
async def verificar_conexao(self) -> bool:
|
30
30
|
sistema_operacional = platform.system().lower()
|
@@ -206,7 +206,7 @@ async def conexao_rdp(task: RpaProcessoRdpDTO) -> RpaRetornoProcessoDTO:
|
|
206
206
|
if sucesso_conexao:
|
207
207
|
console.print("Processo de conexão RDP executado com sucesso.")
|
208
208
|
|
209
|
-
await rdp.clicar_no_titulo()
|
209
|
+
#await rdp.clicar_no_titulo()
|
210
210
|
|
211
211
|
#Altera coluna ativo para true or false
|
212
212
|
await change_robot_status_true(rdp.uuid_robo)
|
@@ -0,0 +1,131 @@
|
|
1
|
+
import asyncio
|
2
|
+
import platform
|
3
|
+
import subprocess
|
4
|
+
import socket
|
5
|
+
import pyautogui
|
6
|
+
import pygetwindow as gw
|
7
|
+
from rich.console import Console
|
8
|
+
from pywinauto import Application
|
9
|
+
from worker_automate_hub.api.rdp_service import send_rdp_action
|
10
|
+
from worker_automate_hub.models.dto.rpa_historico_request_dto import RpaHistoricoStatusEnum, RpaRetornoProcessoDTO
|
11
|
+
from worker_automate_hub.models.dto.rpa_processo_rdp_dto import RpaProcessoRdpDTO
|
12
|
+
from worker_automate_hub.utils.logger import logger
|
13
|
+
from worker_automate_hub.utils.util import worker_sleep
|
14
|
+
|
15
|
+
console = Console()
|
16
|
+
|
17
|
+
class RDPConnection:
|
18
|
+
def __init__(self, task: RpaProcessoRdpDTO):
|
19
|
+
self.task = task
|
20
|
+
self.ip = task.configEntrada.get("ip")
|
21
|
+
self.user = task.configEntrada.get("user")
|
22
|
+
self.password = task.configEntrada.get("password")
|
23
|
+
self.processo = task.configEntrada.get("processo")
|
24
|
+
self.uuid_robo = task.configEntrada.get("uuid_robo")
|
25
|
+
|
26
|
+
async def verificar_conexao(self) -> bool:
|
27
|
+
"""
|
28
|
+
Verifica a conectividade com o host remoto via ping e verificação da porta RDP (3389).
|
29
|
+
"""
|
30
|
+
sistema_operacional = platform.system().lower()
|
31
|
+
console.print(f"Sistema operacional detectado: {sistema_operacional}")
|
32
|
+
|
33
|
+
comando_ping = (
|
34
|
+
["ping", "-n", "1", "-w", "1000", self.ip] if sistema_operacional == "windows" else ["ping", "-c", "1", "-W", "1", self.ip]
|
35
|
+
)
|
36
|
+
console.print(f"Executando comando de ping: {' '.join(comando_ping)}")
|
37
|
+
|
38
|
+
try:
|
39
|
+
resposta_ping = subprocess.run(comando_ping, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
40
|
+
ping_alcancado = resposta_ping.returncode == 0
|
41
|
+
console.print(f"Ping {'sucesso' if ping_alcancado else 'falhou'}")
|
42
|
+
except Exception as e:
|
43
|
+
console.print(f"Erro ao executar ping: {e}")
|
44
|
+
ping_alcancado = False
|
45
|
+
|
46
|
+
porta_aberta = False
|
47
|
+
try:
|
48
|
+
with socket.create_connection((self.ip, 3389), timeout=10):
|
49
|
+
console.print(f"Porta 3389 aberta em {self.ip}")
|
50
|
+
porta_aberta = True
|
51
|
+
except (socket.timeout, OSError) as e:
|
52
|
+
console.print(f"Erro ao verificar a porta RDP: {e}")
|
53
|
+
|
54
|
+
return ping_alcancado and porta_aberta
|
55
|
+
|
56
|
+
async def desligar(self):
|
57
|
+
"""
|
58
|
+
Fecha a conexão RDP interagindo com a janela do cliente RDP.
|
59
|
+
"""
|
60
|
+
janelas_rdp = [
|
61
|
+
win
|
62
|
+
for win in gw.getAllTitles()
|
63
|
+
if self.ip in win
|
64
|
+
]
|
65
|
+
|
66
|
+
if not janelas_rdp:
|
67
|
+
console.print(f"Nenhuma janela RDP encontrada para o IP: {self.ip}")
|
68
|
+
return
|
69
|
+
|
70
|
+
for titulo in janelas_rdp:
|
71
|
+
janela = gw.getWindowsWithTitle(titulo)[0]
|
72
|
+
if not janela:
|
73
|
+
console.print(f"Erro ao localizar a janela: {titulo}")
|
74
|
+
continue
|
75
|
+
|
76
|
+
try:
|
77
|
+
janela = gw.getWindowsWithTitle(titulo)[0]
|
78
|
+
console.print(f"Processando janela: {titulo}")
|
79
|
+
|
80
|
+
app = Application(backend="uia").connect(title=titulo)
|
81
|
+
app_window = app.window(title=titulo)
|
82
|
+
console.print(f"Janela encontrada: {titulo}")
|
83
|
+
|
84
|
+
if not app or not app_window:
|
85
|
+
raise Exception("Nenhuma janela com título correspondente foi encontrada.")
|
86
|
+
|
87
|
+
app_window.set_focus()
|
88
|
+
console.print("Janela RDP ativada.")
|
89
|
+
|
90
|
+
x, y = janela.left, janela.top
|
91
|
+
|
92
|
+
pyautogui.moveTo(x + 2, y + 2)
|
93
|
+
pyautogui.hotkey("alt", "space")
|
94
|
+
await worker_sleep(2)
|
95
|
+
pyautogui.press("down", presses=10, interval=0.1)
|
96
|
+
await worker_sleep(2)
|
97
|
+
pyautogui.press("enter")
|
98
|
+
await worker_sleep(2)
|
99
|
+
pyautogui.press("enter")
|
100
|
+
break
|
101
|
+
|
102
|
+
except Exception as e:
|
103
|
+
console.print(f"Erro ao interagir com a janela {titulo}: {e}")
|
104
|
+
raise(e)
|
105
|
+
|
106
|
+
async def fechar_conexao_rdp(task: RpaProcessoRdpDTO) -> RpaRetornoProcessoDTO:
|
107
|
+
"""
|
108
|
+
Gerencia o processo de fechamento da conexão RDP e retorna um status do processo.
|
109
|
+
"""
|
110
|
+
try:
|
111
|
+
rdp_connection = RDPConnection(task)
|
112
|
+
console.print("Iniciando o fechamento da conexão RDP.")
|
113
|
+
conectado = await rdp_connection.verificar_conexao()
|
114
|
+
|
115
|
+
if not conectado:
|
116
|
+
msg = f"A máquina informada não está ligada. Verifique o IP: {rdp_connection.ip} e a disponibilidade da porta."
|
117
|
+
logger.warning(msg)
|
118
|
+
return RpaRetornoProcessoDTO(sucesso=False, retorno=msg, status=RpaHistoricoStatusEnum.Falha)
|
119
|
+
|
120
|
+
await rdp_connection.desligar()
|
121
|
+
await send_rdp_action(rdp_connection.uuid_robo, "stop")
|
122
|
+
|
123
|
+
return RpaRetornoProcessoDTO(
|
124
|
+
sucesso=True,
|
125
|
+
retorno="Conexão RDP encerrada com sucesso.",
|
126
|
+
status=RpaHistoricoStatusEnum.Sucesso,
|
127
|
+
)
|
128
|
+
except Exception as ex:
|
129
|
+
err_msg = f"Erro ao executar o fechamento da conexão RDP para a máquina {rdp_connection.ip}: {ex}"
|
130
|
+
console.print(err_msg)
|
131
|
+
return RpaRetornoProcessoDTO(sucesso=False, retorno=err_msg, status=RpaHistoricoStatusEnum.Falha)
|
@@ -4,6 +4,7 @@ from worker_automate_hub.tasks.jobs.coleta_dje_process import (
|
|
4
4
|
coleta_dje_start_update,
|
5
5
|
)
|
6
6
|
from worker_automate_hub.tasks.jobs.conexao_rdp import conexao_rdp
|
7
|
+
from worker_automate_hub.tasks.jobs.fechar_conexao_rdp import fechar_conexao_rdp
|
7
8
|
from worker_automate_hub.tasks.jobs.descartes import descartes
|
8
9
|
from worker_automate_hub.tasks.jobs.ecac_estadual_main import (
|
9
10
|
ecac_estadual_main,
|
@@ -61,6 +62,7 @@ task_definitions = {
|
|
61
62
|
"abcfa1ba-d580-465a-aefb-c15ac4514407": descartes,
|
62
63
|
"2c8ee738-7447-4517-aee7-ce2c9d25cea9": transferencias,
|
63
64
|
"855f9e0f-e972-4f52-bc1a-60d1fc244e79": conexao_rdp,
|
65
|
+
"d36b0c83-9cc3-465f-ac80-934099a0e661": fechar_conexao_rdp,
|
64
66
|
"81785803-0594-4bba-9aa0-7f220c200296": coleta_dje_start_update,
|
65
67
|
"3907c8d4-d05b-4d92-b19a-2c4e934f1d78": ecac_estadual_main,
|
66
68
|
"81d2d6e6-e9eb-414d-a939-d220476d2bab": ecac_federal,
|
@@ -4,6 +4,7 @@ worker_automate_hub/api/ahead_service.py,sha256=0tX-i1ACRg3_yOI-_AfFEZ6FNU3L8Zb3
|
|
4
4
|
worker_automate_hub/api/client.py,sha256=tFrIr4mpjvUJ1uU--BCiWa3NT2Ru_yliBsWmfiGt1LA,19720
|
5
5
|
worker_automate_hub/api/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
worker_automate_hub/api/helpers/api_helpers.py,sha256=SkheO2fXexeh-a4shr8Qzsz_kZhuSG0DJ7kbODctRbM,3696
|
7
|
+
worker_automate_hub/api/rdp_service.py,sha256=cDG3RP59U1m2rRX51IMqqKwkQ2-Rgl0PRJ8e4cXyhjs,1547
|
7
8
|
worker_automate_hub/api/rpa_fila_service.py,sha256=K_8EL5P6Y_CHs-f9ZGTsuUUjMd2fu4wN4NieHvMijKs,2100
|
8
9
|
worker_automate_hub/api/rpa_historico_service.py,sha256=GZ3umxvSGNecQsffIRwgfmgpXHDFWq8EiBuAYqtrMNQ,4761
|
9
10
|
worker_automate_hub/api/webhook_service.py,sha256=9KvTv1U02CSYpf_vLnqs4RZqZzR7Mn0v1OVOI451yOM,1762
|
@@ -32,7 +33,7 @@ worker_automate_hub/models/dto/rpa_sistema_dto.py,sha256=sLkmJei8x6sl-1-IXUKDmYQ
|
|
32
33
|
worker_automate_hub/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
33
34
|
worker_automate_hub/tasks/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
34
35
|
worker_automate_hub/tasks/jobs/coleta_dje_process.py,sha256=rf4fW-FaHUl1MS7b03z4cwI3zHfNw8FWxvjvNY3Xn20,28773
|
35
|
-
worker_automate_hub/tasks/jobs/conexao_rdp.py,sha256=
|
36
|
+
worker_automate_hub/tasks/jobs/conexao_rdp.py,sha256=fUjTQ1mcU-whoN23tCdny4CVF2SNN_g1vk2WpIxg5e8,9421
|
36
37
|
worker_automate_hub/tasks/jobs/descartes.py,sha256=RIjrZIzkW77NiKeXbxFN9k872cz3fl9cG1m5TJpjmmY,40134
|
37
38
|
worker_automate_hub/tasks/jobs/ecac_estadual_go.py,sha256=aPckQRlRozFS_OK3C9wNdMCmqO6AM4djwqY2uSSaPmo,20687
|
38
39
|
worker_automate_hub/tasks/jobs/ecac_estadual_main.py,sha256=FFpAdtZLO4uelWZooCVpm4JePv_iDt5nwVKrk1ipZJQ,1599
|
@@ -53,13 +54,14 @@ worker_automate_hub/tasks/jobs/entrada_de_notas_505.py,sha256=jIml8gjXPdI6_x7S9V
|
|
53
54
|
worker_automate_hub/tasks/jobs/entrada_de_notas_7139.py,sha256=oxH2CUJj3UyhYoSxEY2hUr_6wFgZPLcHswEbApIu8VY,15558
|
54
55
|
worker_automate_hub/tasks/jobs/entrada_de_notas_9.py,sha256=Urt_7dZNuyUkSyG9fYb2ArBXzEONXlrqWIesoXeL1EI,50984
|
55
56
|
worker_automate_hub/tasks/jobs/exemplo_processo.py,sha256=3-zxbb-9YHPmSA_K1Qgxp_FwSqg2QDjGBRCLxDZ8QoQ,3451
|
57
|
+
worker_automate_hub/tasks/jobs/fechar_conexao_rdp.py,sha256=zdr988qpz0RSY88yjxLOCwhSIvAUW83qGAgvqK8jZN0,5446
|
56
58
|
worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py,sha256=mZ6mCaz1lYmyFxwC8MVLXPsgynE1VkNKlEzYGsciDiY,10179
|
57
59
|
worker_automate_hub/tasks/jobs/fidc_remessa_cobranca_cnab240.py,sha256=QBGm6eS5JghgNWNqZlk1g2a2iV8LnBLiOTBBL3Giet0,4181
|
58
60
|
worker_automate_hub/tasks/jobs/login_emsys.py,sha256=IoGCIvO4UwmuxOZEn3cvYJlKyhsWvtHvbFk8vwjTroQ,5620
|
59
61
|
worker_automate_hub/tasks/jobs/playground.py,sha256=bdnXv3C7WLQUxt4edGZDfAbRJJ2-q4zuIQaK3GLnaUc,1765
|
60
62
|
worker_automate_hub/tasks/jobs/sped_fiscal.py,sha256=_byvD7i_N3pgPjQd1lc0XNKCFONIPbmvX3_jq5AnbKY,26707
|
61
63
|
worker_automate_hub/tasks/jobs/transferencias.py,sha256=zwCbVTwX15SCeLtvYgAyENeUSIuETx4Z9Cysr1Es8Jo,38013
|
62
|
-
worker_automate_hub/tasks/task_definitions.py,sha256=
|
64
|
+
worker_automate_hub/tasks/task_definitions.py,sha256=KG84tDaTlCpthdYmdR1193BOudELGcoglmIpQpd2PLQ,4606
|
63
65
|
worker_automate_hub/tasks/task_executor.py,sha256=3haqLIb5ZPOpr1g20SED0b6sm_pGFinmZMpE4AJRrlo,9582
|
64
66
|
worker_automate_hub/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
65
67
|
worker_automate_hub/utils/env.py,sha256=TacQjGRO7PUNpttrhTAc5Gnegaiysl2Knsv1P8qfkfs,57
|
@@ -70,7 +72,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
|
|
70
72
|
worker_automate_hub/utils/util.py,sha256=3XNBaYVbJ-KgWyHDKY2jIFuQzgBQs-w1d5iEQZv1D4U,125867
|
71
73
|
worker_automate_hub/utils/utils_nfe_entrada.py,sha256=p5r_L5k7gqCBvV8v6dbLFM6INKiSpGc4Gegid0_YAh4,29017
|
72
74
|
worker_automate_hub/worker.py,sha256=tftQpX8liC-_0_bOUf1YYzXSCvloMQBvjmQ6lzfEE-c,4816
|
73
|
-
worker_automate_hub-0.5.
|
74
|
-
worker_automate_hub-0.5.
|
75
|
-
worker_automate_hub-0.5.
|
76
|
-
worker_automate_hub-0.5.
|
75
|
+
worker_automate_hub-0.5.10.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
76
|
+
worker_automate_hub-0.5.10.dist-info/METADATA,sha256=wuiX3o9vZLo-k3Gz67TSZL3DpBjM9H2zhOUyGHsKKFI,2894
|
77
|
+
worker_automate_hub-0.5.10.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
78
|
+
worker_automate_hub-0.5.10.dist-info/RECORD,,
|
File without changes
|
{worker_automate_hub-0.5.8.dist-info → worker_automate_hub-0.5.10.dist-info}/entry_points.txt
RENAMED
File without changes
|