first commit

This commit is contained in:
Eidan T.
2026-05-09 14:00:04 -04:00
commit e0ec11977c
42 changed files with 4596 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
import paramiko
import os
class SFTPManager():
def __init__(self, sftp_host, sftp_port, sftp_username, sftp_password):
self.sftp_host = sftp_host
self.sftp_username = sftp_username
self.sftp_password = sftp_password
self.sftp_port = sftp_port or 22 # Puerto por defecto: 22
self.ssh_client = None
self.sftp_client = None
def _SFTPConect(self):
self.ssh_client = paramiko.SSHClient()
self.ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # Acepta automáticamente la clave del host
self.ssh_client.connect(self.sftp_host, self.sftp_port, self.sftp_username, self.sftp_password)
self.sftp_client = self.ssh_client.open_sftp()
def _SFTPDisconnect(self):
if self.sftp_client:
self.sftp_client.close()
#print('SFTP desconectado.')
if self.ssh_client:
self.ssh_client.close()
#print('SSH desconectado.')
def uploadFile(self, task, sftp_path):
self._SFTPConect()
file_name = os.path.basename(task.docsend_Path)
pathFTP = os.path.join(sftp_path, file_name)
self.sftp_client.put(task.docsend_Path, pathFTP)
#print(f'Archivo {task.docsendPath} subido exitosamente a {pathFTP}')
self._SFTPDisconnect()