# !/usr/bin/python
# -*- coding: utf-8 -*-
# @Time    : 2020/9/18 12:02
# @Author  : WardenAllen
# @File    : pluto_ftp.py
# @Brief   : 

import paramiko

class PlutoFtp :

    # paramiko's Sftp() object.
    __sftp = object

    def connect_by_pass(self, host, port, uname, pwd):
        transport = paramiko.Transport((host, port))
        transport.connect(username=uname, password=pwd)
        self.__sftp = paramiko.SFTPClient.from_transport(transport)

    def connect_by_key(self, host, port, uname, key_path, key_pass = ''):
        key = paramiko.RSAKey.from_private_key_file(key_path, key_pass)
        transport = paramiko.Transport((host, port))
        transport.connect(username=uname, pkey=key)
        self.__sftp = paramiko.SFTPClient.from_transport(transport)

    def get(self, remote, local, cb = None):
        self.__sftp.get(remote, local, cb)

    def put(self, local, remote, cb = None):
        self.__sftp.put(local, remote, cb)
[((16, 20, 16, 52), 'paramiko.Transport', 'paramiko.Transport', ({(16, 39, 16, 51): '(host, port)'}, {}), '((host, port))', False, 'import paramiko\n'), ((18, 22, 18, 67), 'paramiko.SFTPClient.from_transport', 'paramiko.SFTPClient.from_transport', ({(18, 57, 18, 66): 'transport'}, {}), '(transport)', False, 'import paramiko\n'), ((21, 14, 21, 71), 'paramiko.RSAKey.from_private_key_file', 'paramiko.RSAKey.from_private_key_file', ({(21, 52, 21, 60): 'key_path', (21, 62, 21, 70): 'key_pass'}, {}), '(key_path, key_pass)', False, 'import paramiko\n'), ((22, 20, 22, 52), 'paramiko.Transport', 'paramiko.Transport', ({(22, 39, 22, 51): '(host, port)'}, {}), '((host, port))', False, 'import paramiko\n'), ((24, 22, 24, 67), 'paramiko.SFTPClient.from_transport', 'paramiko.SFTPClient.from_transport', ({(24, 57, 24, 66): 'transport'}, {}), '(transport)', False, 'import paramiko\n')]