edit : 원격 저장으로 변경
This commit is contained in:
29
utils/custom_sftp.py
Normal file
29
utils/custom_sftp.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import paramiko
|
||||
|
||||
class CustomSFTPClient():
|
||||
def __init__(self):
|
||||
host = "192.168.200.230"
|
||||
port = 22
|
||||
id = "fermat"
|
||||
pw = "1234"
|
||||
|
||||
self.ssh_client = paramiko.SSHClient()
|
||||
self.ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
self.ssh_client.connect(hostname=host, port=port, username=id, password=pw)
|
||||
|
||||
self.sftp_client = self.ssh_client.open_sftp()
|
||||
|
||||
def remote_mkdir(self, remote_path):
|
||||
self.sftp_client.mkdir(remote_path)
|
||||
|
||||
def remote_copy_data(self,local_path, remote_path):
|
||||
self.sftp_client.put(local_path, remote_path)
|
||||
|
||||
def client_close(self):
|
||||
self.sftp_client.close()
|
||||
self.ssh_client.close()
|
||||
|
||||
sftp_client = None
|
||||
|
||||
if sftp_client is None:
|
||||
sftp_client = CustomSFTPClient()
|
||||
Reference in New Issue
Block a user