csc-cia-stne 0.0.59__py3-none-any.whl → 0.0.60__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.
- csc_cia_stne/utilitarios/functions/__init__.py +4 -1
- csc_cia_stne/utilitarios/functions/func_rdp.py +103 -0
- {csc_cia_stne-0.0.59.dist-info → csc_cia_stne-0.0.60.dist-info}/METADATA +2 -1
- {csc_cia_stne-0.0.59.dist-info → csc_cia_stne-0.0.60.dist-info}/RECORD +7 -6
- {csc_cia_stne-0.0.59.dist-info → csc_cia_stne-0.0.60.dist-info}/LICENCE +0 -0
- {csc_cia_stne-0.0.59.dist-info → csc_cia_stne-0.0.60.dist-info}/WHEEL +0 -0
- {csc_cia_stne-0.0.59.dist-info → csc_cia_stne-0.0.60.dist-info}/top_level.txt +0 -0
@@ -4,6 +4,7 @@ from .func_b64 import b64decode, b64encode
|
|
4
4
|
from .func_converters import convert_bquery_result_to_json
|
5
5
|
from .func_settings import get_config
|
6
6
|
from .func_get_secret import get_secret
|
7
|
+
from .func_rdp import obter_ip_conexao_rdp, conectar_rdp
|
7
8
|
|
8
9
|
__all__ = [
|
9
10
|
"titulo",
|
@@ -12,5 +13,7 @@ __all__ = [
|
|
12
13
|
"b64decode",
|
13
14
|
"convert_bquery_result_to_json",
|
14
15
|
"get_config",
|
15
|
-
"get_secret"
|
16
|
+
"get_secret",
|
17
|
+
"obter_ip_conexao_rdp",
|
18
|
+
"conectar_rdp"
|
16
19
|
]
|
@@ -0,0 +1,103 @@
|
|
1
|
+
import platform
|
2
|
+
import subprocess
|
3
|
+
import time
|
4
|
+
import pyautogui
|
5
|
+
import psutil
|
6
|
+
import logging
|
7
|
+
|
8
|
+
def obter_ip_conexao_rdp():
|
9
|
+
"""Retorna o ip da conexão RDP
|
10
|
+
|
11
|
+
Returns:
|
12
|
+
str: ip
|
13
|
+
"""
|
14
|
+
|
15
|
+
for proc in psutil.process_iter(['pid', 'name', 'cmdline']):
|
16
|
+
|
17
|
+
if proc.info['name'] == 'mstsc.exe' and proc.info['cmdline']:
|
18
|
+
|
19
|
+
for arg in proc.info['cmdline']:
|
20
|
+
|
21
|
+
if arg.startswith("/v:"): # O argumento '/v:' contém o IP
|
22
|
+
|
23
|
+
return arg.replace("/v:", "").strip()
|
24
|
+
|
25
|
+
return None
|
26
|
+
|
27
|
+
def conectar_rdp(host, usuario, senha):
|
28
|
+
"""Conecta via RDP em uma máquina remota
|
29
|
+
|
30
|
+
Args:
|
31
|
+
|
32
|
+
host (str): ip/host destino
|
33
|
+
usuario (str): usuário
|
34
|
+
senha (str): senha
|
35
|
+
|
36
|
+
Returns:
|
37
|
+
bool: True/False
|
38
|
+
"""
|
39
|
+
|
40
|
+
sistema = platform.system()
|
41
|
+
|
42
|
+
if sistema == "Windows":
|
43
|
+
|
44
|
+
try:
|
45
|
+
|
46
|
+
# Inicia o mstsc
|
47
|
+
cmd_conexao = f"start mstsc /v:{host} /f"
|
48
|
+
subprocess.run(cmd_conexao, shell=True)
|
49
|
+
|
50
|
+
# Aguarda um tempo para verificar se a conexão foi feita
|
51
|
+
time.sleep(3) # Dá tempo para o usuário tentar logar
|
52
|
+
pyautogui.typewrite(senha)
|
53
|
+
pyautogui.press('enter')
|
54
|
+
time.sleep(2)
|
55
|
+
pyautogui.press('left')
|
56
|
+
pyautogui.press('enter')
|
57
|
+
time.sleep(5)
|
58
|
+
return True
|
59
|
+
|
60
|
+
except Exception as e:
|
61
|
+
|
62
|
+
logging.error(f"Falha ao tentar logar via RDP (Windows)\nErro: {str(e)}")
|
63
|
+
return False
|
64
|
+
|
65
|
+
elif sistema == "Linux":
|
66
|
+
|
67
|
+
# Comando para executar a conexao com o xfreerdp
|
68
|
+
# Para instalar: sudo apt install freerdp2-x11
|
69
|
+
comando_rdp = f"""xfreerdp /u:{usuario} /p:{senha} /v:{host} /size:1920x1080"""
|
70
|
+
|
71
|
+
# Executar o comando e capturar saída
|
72
|
+
try:
|
73
|
+
|
74
|
+
processo_rdp = subprocess.Popen(
|
75
|
+
comando_rdp,
|
76
|
+
shell=True,
|
77
|
+
stdout=subprocess.PIPE,
|
78
|
+
stderr=subprocess.PIPE,
|
79
|
+
text=True
|
80
|
+
)
|
81
|
+
|
82
|
+
except Exception as e:
|
83
|
+
|
84
|
+
raise Exception(f"Falha ao executar o comando de conexão RDP no Linux. Você possui o xfreerdp instalado? (sudo apt install freerdp2-x11)\nErro: {str(e)}")
|
85
|
+
|
86
|
+
# Aguarda 10 segundos, para aparecer o banner azul
|
87
|
+
time.sleep(10)
|
88
|
+
|
89
|
+
# Se a conexão foi bem-sucedida, retornar True
|
90
|
+
if processo_rdp.poll() is None:
|
91
|
+
|
92
|
+
# Clica no 'enter', no banner azul
|
93
|
+
pyautogui.press('enter')
|
94
|
+
return True
|
95
|
+
|
96
|
+
else:
|
97
|
+
|
98
|
+
return False
|
99
|
+
|
100
|
+
else:
|
101
|
+
|
102
|
+
raise Exception("Sistema operacional não suportado (Somente 'Windows' ou 'Linux').")
|
103
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: csc_cia_stne
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.60
|
4
4
|
Summary: Biblioteca do time CSC-CIA utilizada no desenvolvimento de RPAs
|
5
5
|
License: MIT
|
6
6
|
Keywords: karavela,csc,cia,stone,rpa,botcity,stne
|
@@ -26,6 +26,7 @@ Requires-Dist: webdriver-manager
|
|
26
26
|
Requires-Dist: botcity-framework-web
|
27
27
|
Requires-Dist: email-validator
|
28
28
|
Requires-Dist: botcity-maestro-sdk
|
29
|
+
Requires-Dist: psutil
|
29
30
|
|
30
31
|
Essa biblioteca é desenvolvida e atualizada pelo time **CSC-CIA** da **Stone**
|
31
32
|
|
@@ -13,10 +13,11 @@ csc_cia_stne/slack.py,sha256=33_UNF7M529eIuWjmzSJFEZ4RmVNkFkuVxvxwsKY1tQ,8126
|
|
13
13
|
csc_cia_stne/stne_admin.py,sha256=vnGSEzcmqWE42vg71oEuoRg6ENaGsZsXFOjxduSH4KU,23561
|
14
14
|
csc_cia_stne/web.py,sha256=_pc6BzPy2x0RvqtZsByjtKcSuUqlVTevfmmmKbVWLhA,15417
|
15
15
|
csc_cia_stne/utilitarios/__init__.py,sha256=0FrfH9XklutPS4QlbGjNYPulNfO2LFQoFXRnJQm-pKE,283
|
16
|
-
csc_cia_stne/utilitarios/functions/__init__.py,sha256=
|
16
|
+
csc_cia_stne/utilitarios/functions/__init__.py,sha256=nUcjSI23FxfX18AQ8Q_Gimyxme35JTyfCYNcIypPfNU,527
|
17
17
|
csc_cia_stne/utilitarios/functions/func_b64.py,sha256=XGU34BIQQXWXBS0yM2B4A2wDlcrMl1unIJXjq4lpLnk,1254
|
18
18
|
csc_cia_stne/utilitarios/functions/func_converters.py,sha256=EY1zvlBaRX7G1MceVSiRXwwKDQDZwUO9iECBL0fe5iU,481
|
19
19
|
csc_cia_stne/utilitarios/functions/func_get_secret.py,sha256=khTtUTE-acdA9lIM8l7weejDSqoTYlf59ypBdC_F_lw,2150
|
20
|
+
csc_cia_stne/utilitarios/functions/func_rdp.py,sha256=6nUKxa_sHqpz1kvdnOEyKkVopZY3QEByqZ6Sfw64gOs,2791
|
20
21
|
csc_cia_stne/utilitarios/functions/func_recriar_pastas.py,sha256=4whZpB3aJQaCPJ3osMAQpKrzEhqYtJbljGWlx_OvKIM,826
|
21
22
|
csc_cia_stne/utilitarios/functions/func_settings.py,sha256=XwlfqdcfocXQ8kTsDKZ6GsAtpzr0_u44AOTIMtdem7U,2059
|
22
23
|
csc_cia_stne/utilitarios/functions/func_titulo.py,sha256=bH4tYxovTARF-g2kWUK_GIzzXt8egbVdp6mWD6fc_3I,5345
|
@@ -25,8 +26,8 @@ csc_cia_stne/utilitarios/validations/GoogleDriveValidator.py,sha256=PBo-AV2bjR__
|
|
25
26
|
csc_cia_stne/utilitarios/validations/ServiceNowValidator.py,sha256=yleKUIo1ZfyloP9fDPNjv3JJXdLcocT81WIgRSYmqEA,14423
|
26
27
|
csc_cia_stne/utilitarios/validations/__init__.py,sha256=O_qyEU2ji3u6LHUXZCXvUFsMpoMWL625qqHTXyXivTA,106
|
27
28
|
csc_cia_stne/utilitarios/validations/web_validator.py,sha256=HYKYSpDv1RvRjZIuwTPt-AbEz-9392MxM_O329iYuSA,5722
|
28
|
-
csc_cia_stne-0.0.
|
29
|
-
csc_cia_stne-0.0.
|
30
|
-
csc_cia_stne-0.0.
|
31
|
-
csc_cia_stne-0.0.
|
32
|
-
csc_cia_stne-0.0.
|
29
|
+
csc_cia_stne-0.0.60.dist-info/LICENCE,sha256=LPGMtgKki2C3KEZP7hDhA1HBrlq5JCHkIeStUCLEMx4,1073
|
30
|
+
csc_cia_stne-0.0.60.dist-info/METADATA,sha256=sG1SMPQd88mTGRsZsYElFnIPoJ6wiwpWM9aOgw-9534,1287
|
31
|
+
csc_cia_stne-0.0.60.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
32
|
+
csc_cia_stne-0.0.60.dist-info/top_level.txt,sha256=ldo7GVv3tQx5KJvwBzdZzzQmjPys2NDVVn1rv0BOF2Q,13
|
33
|
+
csc_cia_stne-0.0.60.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|