worker-automate-hub 0.5.9__tar.gz → 0.5.10__tar.gz

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.

Files changed (77) hide show
  1. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/PKG-INFO +1 -1
  2. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/pyproject.toml +1 -1
  3. worker_automate_hub-0.5.10/worker_automate_hub/api/rdp_service.py +38 -0
  4. worker_automate_hub-0.5.10/worker_automate_hub/tasks/jobs/fechar_conexao_rdp.py +131 -0
  5. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/task_definitions.py +2 -0
  6. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/README.md +0 -0
  7. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/__init__.py +0 -0
  8. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/api/__init__.py +0 -0
  9. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/api/ahead_service.py +0 -0
  10. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/api/client.py +0 -0
  11. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/api/helpers/__init__.py +0 -0
  12. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/api/helpers/api_helpers.py +0 -0
  13. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/api/rpa_fila_service.py +0 -0
  14. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/api/rpa_historico_service.py +0 -0
  15. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/api/webhook_service.py +0 -0
  16. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/cli.py +0 -0
  17. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/config/__init__.py +0 -0
  18. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/config/settings.py +0 -0
  19. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/config.py +0 -0
  20. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/core/so_manipulation.py +0 -0
  21. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/decorators/__init__.py +0 -0
  22. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/decorators/deprecation.py +0 -0
  23. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/decorators/rate_limit.py +0 -0
  24. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/decorators/repeat.py +0 -0
  25. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/decorators/retry.py +0 -0
  26. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/decorators/singleton.py +0 -0
  27. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/decorators/timeit.py +0 -0
  28. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/models/__init__.py +0 -0
  29. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/models/dao/__init__.py +0 -0
  30. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/models/dao/rpa_configuracao.py +0 -0
  31. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/models/dao/rpa_historico.py +0 -0
  32. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/models/dao/rpa_processo.py +0 -0
  33. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/models/dto/__init__.py +0 -0
  34. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/models/dto/rpa_historico_request_dto.py +0 -0
  35. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/models/dto/rpa_processo_entrada_dto.py +0 -0
  36. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/models/dto/rpa_processo_rdp_dto.py +0 -0
  37. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/models/dto/rpa_sistema_dto.py +0 -0
  38. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/__init__.py +0 -0
  39. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/__init__.py +0 -0
  40. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/coleta_dje_process.py +0 -0
  41. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/conexao_rdp.py +0 -0
  42. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/descartes.py +0 -0
  43. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/ecac_estadual_go.py +0 -0
  44. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/ecac_estadual_main.py +0 -0
  45. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/ecac_estadual_mt.py +0 -0
  46. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/ecac_estadual_sc.py +0 -0
  47. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/ecac_estadual_sp.py +0 -0
  48. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/ecac_federal.py +0 -0
  49. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/entrada_de_notas_15.py +0 -0
  50. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/entrada_de_notas_16.py +0 -0
  51. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/entrada_de_notas_207.py +0 -0
  52. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/entrada_de_notas_32.py +0 -0
  53. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/entrada_de_notas_33.py +0 -0
  54. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/entrada_de_notas_34.py +0 -0
  55. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/entrada_de_notas_36.py +0 -0
  56. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/entrada_de_notas_39.py +0 -0
  57. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/entrada_de_notas_500.py +0 -0
  58. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/entrada_de_notas_505.py +0 -0
  59. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/entrada_de_notas_7139.py +0 -0
  60. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/entrada_de_notas_9.py +0 -0
  61. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/exemplo_processo.py +0 -0
  62. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/fidc_gerar_nosso_numero.py +0 -0
  63. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/fidc_remessa_cobranca_cnab240.py +0 -0
  64. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/login_emsys.py +0 -0
  65. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/playground.py +0 -0
  66. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/sped_fiscal.py +0 -0
  67. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/jobs/transferencias.py +0 -0
  68. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/tasks/task_executor.py +0 -0
  69. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/utils/__init__.py +0 -0
  70. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/utils/env.py +0 -0
  71. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/utils/get_creds_gworkspace.py +0 -0
  72. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/utils/logger.py +0 -0
  73. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/utils/toast.py +0 -0
  74. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/utils/updater.py +0 -0
  75. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/utils/util.py +0 -0
  76. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/utils/utils_nfe_entrada.py +0 -0
  77. {worker_automate_hub-0.5.9 → worker_automate_hub-0.5.10}/worker_automate_hub/worker.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: worker-automate-hub
3
- Version: 0.5.9
3
+ Version: 0.5.10
4
4
  Summary: Worker Automate HUB é uma aplicação para automatizar rotinas de RPA nos ambientes Argenta.
5
5
  Author: Joel Paim
6
6
  Requires-Python: >=3.12,<4.0
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "worker-automate-hub"
3
- version = "0.5.9"
3
+ version = "0.5.10"
4
4
  description = "Worker Automate HUB é uma aplicação para automatizar rotinas de RPA nos ambientes Argenta."
5
5
  authors = ["Joel Paim"]
6
6
  readme = "README.md"
@@ -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)}
@@ -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,