csc-cia-stne 0.0.76__tar.gz → 0.0.78__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.
Files changed (39) hide show
  1. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/PKG-INFO +1 -1
  2. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/pyproject.toml +1 -1
  3. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/bc_sta.py +1 -0
  4. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/utilitarios/functions/func_rdp.py +53 -11
  5. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne.egg-info/PKG-INFO +1 -1
  6. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/LICENCE +0 -0
  7. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/README.md +0 -0
  8. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/README_PYPI.md +0 -0
  9. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/setup.cfg +0 -0
  10. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/__init__.py +0 -0
  11. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/bc_correios.py +0 -0
  12. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/email.py +0 -0
  13. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/gcp_bigquery.py +0 -0
  14. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/google_drive.py +0 -0
  15. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/karavela.py +0 -0
  16. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/logger_json.py +0 -0
  17. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/logger_rich.py +0 -0
  18. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/provio.py +0 -0
  19. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/servicenow.py +0 -0
  20. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/slack.py +0 -0
  21. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/stne_admin.py +0 -0
  22. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/utilitarios/__init__.py +0 -0
  23. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/utilitarios/functions/__init__.py +0 -0
  24. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/utilitarios/functions/func_b64.py +0 -0
  25. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/utilitarios/functions/func_converters.py +0 -0
  26. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/utilitarios/functions/func_get_secret.py +0 -0
  27. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/utilitarios/functions/func_recriar_pastas.py +0 -0
  28. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/utilitarios/functions/func_settings.py +0 -0
  29. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/utilitarios/functions/func_titulo.py +0 -0
  30. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/utilitarios/validations/GcpBigQueryValidator.py +0 -0
  31. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/utilitarios/validations/GoogleDriveValidator.py +0 -0
  32. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/utilitarios/validations/ServiceNowValidator.py +0 -0
  33. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/utilitarios/validations/__init__.py +0 -0
  34. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/utilitarios/validations/web_validator.py +0 -0
  35. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne/web.py +0 -0
  36. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne.egg-info/SOURCES.txt +0 -0
  37. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne.egg-info/dependency_links.txt +0 -0
  38. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne.egg-info/requires.txt +0 -0
  39. {csc_cia_stne-0.0.76 → csc_cia_stne-0.0.78}/src/csc_cia_stne.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: csc_cia_stne
3
- Version: 0.0.76
3
+ Version: 0.0.78
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "csc_cia_stne"
7
- version = "0.0.76"
7
+ version = "0.0.78"
8
8
  license = { text = "MIT" }
9
9
  description = "Biblioteca do time CSC-CIA utilizada no desenvolvimento de RPAs"
10
10
  keywords = ["karavela", "csc", "cia", "stone", "rpa", "botcity", "stne"]
@@ -6,6 +6,7 @@ import xml.etree.ElementTree as ET
6
6
  from xml.dom.minidom import parseString
7
7
  from pydantic import BaseModel, ValidationError, field_validator, Field, HttpUrl
8
8
  from typing import Literal, Dict, Union, Optional, List
9
+ from datetime import datetime
9
10
 
10
11
  log = logging.getLogger('__main__')
11
12
 
@@ -3,6 +3,7 @@ import subprocess
3
3
  import time
4
4
  import pyautogui
5
5
  import psutil
6
+ import pygetwindow as gw
6
7
  import logging
7
8
  pyautogui.USE_MOUSEINFO = False
8
9
  log = logging.getLogger('__main__')
@@ -26,7 +27,21 @@ def obter_ip_conexao_rdp():
26
27
 
27
28
  return None
28
29
 
29
- def conectar_rdp(host, usuario, senha):
30
+ def verificar_sessao_rdp()->bool:
31
+ """Verifica se a sessão RDP está ativa"""
32
+ # Verifica se o processo mstsc.exe está rodando
33
+ for proc in psutil.process_iter(['name']):
34
+ if proc.info['name'] == 'mstsc.exe':
35
+ #return True
36
+
37
+ # Verifica se a janela da Área de Trabalho Remota está aberta
38
+ for window in gw.getAllTitles():
39
+ if "Área de Trabalho Remota" in window or "Remote Desktop" in window:
40
+ return True
41
+
42
+ return False
43
+
44
+ def conectar_rdp(host:str, usuario:str, senha:str)->bool:
30
45
  """Conecta via RDP em uma máquina remota
31
46
 
32
47
  Args:
@@ -45,23 +60,50 @@ def conectar_rdp(host, usuario, senha):
45
60
 
46
61
  try:
47
62
 
48
- # Inicia o mstsc
49
- cmd_conexao = f"start mstsc /v:{host} /f"
50
- subprocess.run(cmd_conexao, shell=True)
63
+ def criar_arquivo_rdp(host, usuario, caminho_rdp="conexao.rdp")->str:
64
+ """Cria um arquivo .rdp para conexão RDP
65
+ Args:
66
+ host (str): host do computador remoto
67
+ usuario (str): Usuário
68
+ caminho_rdp (str): Caminho do arquivo .rdp
69
+ Returns:
70
+ str: Caminho do arquivo .rdp
71
+ """
72
+ conteudo_rdp = f"""
73
+ screen mode id:i:2
74
+ desktopwidth:i:1920
75
+ desktopheight:i:1080
76
+ session bpp:i:32
77
+ winposstr:s:0,1,0,0,800,600
78
+ full address:s:{host}
79
+ username:s:{usuario}
80
+ """
81
+ with open(caminho_rdp, "w") as arquivo:
82
+ arquivo.write(conteudo_rdp.strip())
83
+
84
+ return caminho_rdp
51
85
 
52
- # Aguarda um tempo para verificar se a conexão foi feita
53
- time.sleep(3) # tempo para o usuário tentar logar
54
- pyautogui.typewrite(senha)
86
+ caminho_rdp = criar_arquivo_rdp(host, usuario)
87
+ subprocess.run(f"start mstsc {caminho_rdp}", shell=True)
88
+ # Espera a conexão ser feita e confirma que realmente quer fazer a conexão com o computador remoto de forma insegura (certificado)
89
+ time.sleep(10)
90
+ pyautogui.press('left')
91
+ pyautogui.press('enter')
92
+ # Espera 3 segundos para digitar a senha e dar enter
93
+ time.sleep(3)
94
+ pyautogui.write(senha)
55
95
  pyautogui.press('enter')
56
- time.sleep(2)
96
+ # Espera 5 segundos para aparecer a tela sobre o certificado e aceitar a conexão de forma insegura (certificado)
97
+ time.sleep(5)
57
98
  pyautogui.press('left')
58
99
  pyautogui.press('enter')
100
+ # Aguarda 5 segundos e verifica se a conexão foi feita com sucesso
59
101
  time.sleep(5)
60
- return True
102
+ return verificar_sessao_rdp()
61
103
 
62
104
  except Exception as e:
63
-
64
- log.error(f"Falha ao tentar logar via RDP (Windows)\nErro: {str(e)}")
105
+
106
+ log.error(f"Erro ao conectar à área de trabalho remota:\n{e}")
65
107
  return False
66
108
 
67
109
  elif sistema == "Linux":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: csc_cia_stne
3
- Version: 0.0.76
3
+ Version: 0.0.78
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
File without changes
File without changes
File without changes