worker-automate-hub 0.4.427__py3-none-any.whl → 0.4.429__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- worker_automate_hub/tasks/jobs/conexao_rdp.py +33 -32
- {worker_automate_hub-0.4.427.dist-info → worker_automate_hub-0.4.429.dist-info}/METADATA +1 -1
- {worker_automate_hub-0.4.427.dist-info → worker_automate_hub-0.4.429.dist-info}/RECORD +5 -5
- {worker_automate_hub-0.4.427.dist-info → worker_automate_hub-0.4.429.dist-info}/WHEEL +0 -0
- {worker_automate_hub-0.4.427.dist-info → worker_automate_hub-0.4.429.dist-info}/entry_points.txt +0 -0
@@ -10,6 +10,7 @@ from pywinauto import Application
|
|
10
10
|
from worker_automate_hub.models.dto.rpa_historico_request_dto import RpaHistoricoStatusEnum, RpaRetornoProcessoDTO
|
11
11
|
from worker_automate_hub.models.dto.rpa_processo_rdp_dto import RpaProcessoRdpDTO
|
12
12
|
from worker_automate_hub.utils.logger import logger
|
13
|
+
from worker_automate_hub.utils.util import worker_sleep
|
13
14
|
|
14
15
|
console = Console()
|
15
16
|
|
@@ -25,16 +26,16 @@ class RDPConnection:
|
|
25
26
|
|
26
27
|
async def verificar_conexao(self) -> bool:
|
27
28
|
sistema_operacional = platform.system().lower()
|
28
|
-
|
29
|
+
console.print(f"Sistema operacional detectado: {sistema_operacional}")
|
29
30
|
if sistema_operacional == "windows":
|
30
31
|
comando_ping = ["ping", "-n", "1", "-w", "1000", self.ip]
|
31
32
|
else:
|
32
33
|
comando_ping = ["ping", "-c", "1", "-W", "1", self.ip]
|
33
|
-
|
34
|
+
console.print(f"Executando comando de ping: {' '.join(comando_ping)}")
|
34
35
|
try:
|
35
36
|
resposta_ping = subprocess.run(comando_ping, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
36
37
|
ping_alcancado = resposta_ping.returncode == 0
|
37
|
-
|
38
|
+
console.print(f"Ping {'sucesso' if ping_alcancado else 'falhou'}")
|
38
39
|
except Exception as e:
|
39
40
|
logger.error(f"Erro ao executar ping: {e}")
|
40
41
|
ping_alcancado = False
|
@@ -42,11 +43,11 @@ class RDPConnection:
|
|
42
43
|
porta_aberta = False
|
43
44
|
try:
|
44
45
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
45
|
-
sock.settimeout(
|
46
|
-
|
46
|
+
sock.settimeout(10)
|
47
|
+
console.print(f"Verificando porta 3389 em {self.ip}")
|
47
48
|
resposta_porta = sock.connect_ex((self.ip, 3389))
|
48
49
|
porta_aberta = resposta_porta == 0
|
49
|
-
|
50
|
+
console.print(f"Porta 3389 {'aberta' if porta_aberta else 'fechada'}")
|
50
51
|
except Exception as e:
|
51
52
|
logger.error(f"Erro ao verificar a porta RDP: {e}")
|
52
53
|
porta_aberta = False
|
@@ -68,10 +69,10 @@ class RDPConnection:
|
|
68
69
|
for titulo in janelas_rdp:
|
69
70
|
janela = gw.getWindowsWithTitle(titulo)[0]
|
70
71
|
if not janela:
|
71
|
-
print(f"Erro ao localizar a janela: {titulo}")
|
72
|
+
console.print(f"Erro ao localizar a janela: {titulo}")
|
72
73
|
continue
|
73
74
|
|
74
|
-
print(f"Processando janela: {titulo}")
|
75
|
+
console.print(f"Processando janela: {titulo}")
|
75
76
|
|
76
77
|
# Obtém as coordenadas da janela
|
77
78
|
x, y = janela.left, janela.top
|
@@ -81,27 +82,27 @@ class RDPConnection:
|
|
81
82
|
pyautogui.moveTo(x + 10, y + 10) # Ajuste para alinhar ao título da janela
|
82
83
|
pyautogui.click(button="right")
|
83
84
|
|
84
|
-
await
|
85
|
+
await worker_sleep(5)
|
85
86
|
pyautogui.press("down", presses=7, interval=0.1)
|
86
|
-
await
|
87
|
+
await worker_sleep(5)
|
87
88
|
pyautogui.hotkey("enter")
|
88
|
-
await
|
89
|
+
await worker_sleep(5)
|
89
90
|
pyautogui.hotkey("enter")
|
90
91
|
|
91
92
|
except Exception as e:
|
92
|
-
print(f"Erro ao interagir com a janela {titulo}: {e}")
|
93
|
+
console.print(f"Erro ao interagir com a janela {titulo}: {e}")
|
93
94
|
|
94
95
|
async def conectar(self):
|
95
|
-
|
96
|
+
console.print(f"Iniciando cliente RDP para {self.ip}")
|
96
97
|
try:
|
97
98
|
pyautogui.hotkey("win", "d")
|
98
|
-
await
|
99
|
-
|
99
|
+
await worker_sleep(5) # Tempo para garantir que todas as janelas sejam minimizadas
|
100
|
+
console.print("Todas as janelas minimizadas com sucesso.")
|
100
101
|
|
101
102
|
subprocess.Popen(["mstsc", f"/v:{self.ip}"], close_fds=True, start_new_session=True)
|
102
|
-
await
|
103
|
+
await worker_sleep(10) # Tempo aumentado para garantir abertura
|
103
104
|
|
104
|
-
|
105
|
+
console.print("Procurando janela 'Conexão de Área de Trabalho Remota'")
|
105
106
|
windows = gw.getWindowsWithTitle("Conexão de Área de Trabalho Remota")
|
106
107
|
if not windows:
|
107
108
|
logger.warning("Tentando encontrar janela com título em inglês 'Remote Desktop Connection'")
|
@@ -112,12 +113,12 @@ class RDPConnection:
|
|
112
113
|
return False
|
113
114
|
|
114
115
|
rdp_window = windows[0]
|
115
|
-
|
116
|
+
console.print(f"Janela '{rdp_window.title}' encontrada. Focando na janela.")
|
116
117
|
|
117
118
|
# Restaurar janela se estiver minimizada
|
118
119
|
if rdp_window.isMinimized:
|
119
120
|
rdp_window.restore()
|
120
|
-
await
|
121
|
+
await worker_sleep(5)
|
121
122
|
|
122
123
|
# Redimensionar para 50% da tela
|
123
124
|
screen_width, screen_height = pyautogui.size()
|
@@ -125,14 +126,14 @@ class RDPConnection:
|
|
125
126
|
new_height = screen_height // 2
|
126
127
|
rdp_window.resizeTo(new_width, new_height)
|
127
128
|
rdp_window.moveTo(screen_width // 4, screen_height // 4)
|
128
|
-
|
129
|
+
console.print(f"Janela redimensionada para {new_width}x{new_height}.")
|
129
130
|
|
130
131
|
rdp_window.activate()
|
131
|
-
await
|
132
|
+
await worker_sleep(5) # Tempo extra para garantir que a janela está ativa
|
132
133
|
|
133
134
|
# Clique para garantir o foco
|
134
135
|
pyautogui.click(rdp_window.left + 50, rdp_window.top + 50)
|
135
|
-
await
|
136
|
+
await worker_sleep(3)
|
136
137
|
|
137
138
|
# Inserir credenciais
|
138
139
|
|
@@ -143,24 +144,24 @@ class RDPConnection:
|
|
143
144
|
edit_field = dialog.child_window(auto_id="EditField_1", control_type="Edit")
|
144
145
|
|
145
146
|
if edit_field.exists():
|
146
|
-
|
147
|
+
console.print("Inserindo usuário.")
|
147
148
|
pyautogui.write(self.user, interval=0.1)
|
148
149
|
pyautogui.press("tab")
|
149
|
-
await
|
150
|
+
await worker_sleep(5)
|
150
151
|
except:
|
151
152
|
pass
|
152
153
|
|
153
|
-
|
154
|
+
console.print("Inserindo senha.")
|
154
155
|
pyautogui.write(self.password, interval=0.1)
|
155
156
|
pyautogui.press("enter")
|
156
|
-
await
|
157
|
+
await worker_sleep(5)
|
157
158
|
pyautogui.press("left")
|
158
|
-
await
|
159
|
+
await worker_sleep(5)
|
159
160
|
pyautogui.press("enter")
|
160
|
-
|
161
|
-
await
|
161
|
+
console.print("Credenciais inseridas.")
|
162
|
+
await worker_sleep(5) # Tempo para conexão ser concluída
|
162
163
|
|
163
|
-
|
164
|
+
console.print("Conexão RDP ativa. Mantendo o script em execução.")
|
164
165
|
return True
|
165
166
|
except Exception as e:
|
166
167
|
logger.error(f"Erro ao tentar conectar via RDP: {e}")
|
@@ -168,7 +169,7 @@ class RDPConnection:
|
|
168
169
|
|
169
170
|
async def conexao_rdp(task: RpaProcessoRdpDTO) -> RpaRetornoProcessoDTO:
|
170
171
|
try:
|
171
|
-
|
172
|
+
console.print("Iniciando processo de conexão RDP.")
|
172
173
|
rdp = RDPConnection(task)
|
173
174
|
conectado = await rdp.verificar_conexao()
|
174
175
|
if not conectado:
|
@@ -180,7 +181,7 @@ async def conexao_rdp(task: RpaProcessoRdpDTO) -> RpaRetornoProcessoDTO:
|
|
180
181
|
)
|
181
182
|
sucesso_conexao = await rdp.conectar()
|
182
183
|
if sucesso_conexao:
|
183
|
-
|
184
|
+
console.print("Processo de conexão RDP executado com sucesso.")
|
184
185
|
|
185
186
|
await rdp.clicar_no_titulo()
|
186
187
|
|
@@ -30,7 +30,7 @@ worker_automate_hub/models/dto/rpa_sistema_dto.py,sha256=sLkmJei8x6sl-1-IXUKDmYQ
|
|
30
30
|
worker_automate_hub/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
31
31
|
worker_automate_hub/tasks/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
32
32
|
worker_automate_hub/tasks/jobs/coleta_dje_process.py,sha256=rf4fW-FaHUl1MS7b03z4cwI3zHfNw8FWxvjvNY3Xn20,28773
|
33
|
-
worker_automate_hub/tasks/jobs/conexao_rdp.py,sha256=
|
33
|
+
worker_automate_hub/tasks/jobs/conexao_rdp.py,sha256=Bh0LbRULxW-SrESMtcX1SYnmZLbDI49l5ckYNnNlZCM,9045
|
34
34
|
worker_automate_hub/tasks/jobs/descartes.py,sha256=RIjrZIzkW77NiKeXbxFN9k872cz3fl9cG1m5TJpjmmY,40134
|
35
35
|
worker_automate_hub/tasks/jobs/ecac_estadual_go.py,sha256=aPckQRlRozFS_OK3C9wNdMCmqO6AM4djwqY2uSSaPmo,20687
|
36
36
|
worker_automate_hub/tasks/jobs/ecac_estadual_main.py,sha256=FFpAdtZLO4uelWZooCVpm4JePv_iDt5nwVKrk1ipZJQ,1599
|
@@ -68,7 +68,7 @@ worker_automate_hub/utils/updater.py,sha256=en2FCGhI8aZ-JNP3LQm64NJDc4awCNW7UhbV
|
|
68
68
|
worker_automate_hub/utils/util.py,sha256=JpRM3ltfGNkzui0RAjUK1FhWT3aWUjt3ljEyQez3Sbw,120156
|
69
69
|
worker_automate_hub/utils/utils_nfe_entrada.py,sha256=7ju688sD52y30taGSm5rPMGdQyByUUwveLeKV4ImEiE,28401
|
70
70
|
worker_automate_hub/worker.py,sha256=KDBU3L2kVobndrnN5coRZFTwVmBLKmPJjRv20sCo5Hc,4697
|
71
|
-
worker_automate_hub-0.4.
|
72
|
-
worker_automate_hub-0.4.
|
73
|
-
worker_automate_hub-0.4.
|
74
|
-
worker_automate_hub-0.4.
|
71
|
+
worker_automate_hub-0.4.429.dist-info/entry_points.txt,sha256=sddyhjx57I08RY8X7UxcTpdoOsWULAWNKN9Xr6pp_Kw,54
|
72
|
+
worker_automate_hub-0.4.429.dist-info/METADATA,sha256=EHC72UJsPvLQvdYEYAi_cS3py8rpLYDWVE6IDTuifxQ,2895
|
73
|
+
worker_automate_hub-0.4.429.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
74
|
+
worker_automate_hub-0.4.429.dist-info/RECORD,,
|
File without changes
|
{worker_automate_hub-0.4.427.dist-info → worker_automate_hub-0.4.429.dist-info}/entry_points.txt
RENAMED
File without changes
|