<commit_before>'''
Create a SCP side-channel to transfer a file to remote network device
'''

from __future__ import print_function
from __future__ import unicode_literals

import paramiko
import scp


class SCPConn(object):
    '''
    Establish an SCP channel to the remote network

    SCP requires a separate SSH connection at least to Cisco IOS
    '''

    def __init__(self, ssh_conn):
        self.ip = ssh_conn.ip
        self.port = ssh_conn.port
        self.username = ssh_conn.username
        self.password = <PASSWORD>
        self.secret = ssh_conn.secret
        self.device_type = ssh_conn.device_type

        self.establish_scp_conn()


    def establish_scp_conn(self):
        '''
        Establish the SCP connection
        '''

        self.scp_conn = paramiko.SSHClient()
        self.scp_conn.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        self.scp_conn.connect(hostname=self.ip, port=self.port, username=self.username,
                              password=self.password, look_for_keys=False, allow_agent=False,
                              timeout=8)

        self.scp_client = scp.SCPClient(self.scp_conn.get_transport())


    def scp_transfer_file(self, source_file, dest_file):
        '''
        Transfer file using SCP
        '''

        print("Transferring file: {}".format(source_file))
        self.scp_client.put(source_file, dest_file)


    def close_conn(self):
        '''
        Close the SCP connection
        '''

        self.scp_conn.close()
<commit_msg>Updating SCP handler<commit_after>'''
Create a SCP side-channel to transfer a file to remote network device
'''

from __future__ import print_function
from __future__ import unicode_literals

import paramiko
import scp

from netmiko.netmiko_globals import MAX_BUFFER


class SCPConn(object):
    '''
    Establish an SCP channel to the remote network

    SCP requires a separate SSH connection at least to Cisco IOS
    '''

    def __init__(self, ssh_conn):
        self.ip = ssh_conn.ip
        self.port = ssh_conn.port
        self.username = ssh_conn.username
        self.password = <PASSWORD>
        self.secret = ssh_conn.secret
        self.device_type = ssh_conn.device_type

        self.establish_scp_conn()


    def establish_scp_conn(self):
        '''
        Establish the SCP connection
        '''

        self.scp_conn = paramiko.SSHClient()
        self.scp_conn.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        self.scp_conn.connect(hostname=self.ip, port=self.port, username=self.username,
                              password=<PASSWORD>, look_for_keys=False, allow_agent=False,
                              timeout=8)

        self.scp_client = scp.SCPClient(self.scp_conn.get_transport())


    def scp_transfer_file(self, source_file, dest_file):
        '''
        Transfer file using SCP
        '''

        print("Transferring file: {}".format(source_file))
        self.scp_client.put(source_file, dest_file)


    def close(self):
        '''
        Close the SCP connection
        '''

        self.scp_conn.close()

{'fraction_non_alphanumeric': 0.0878269292864062, 'fraction_numerical': 0.0006457862447529867, 'mean_word_length': 2.4575892857142856, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4402900', 'n_tokens_mistral': 962, 'n_tokens_neox': 917, 'n_words': 206}