<commit_before>from netmiko.ssh_connection import SSHConnection
from netmiko.netmiko_globals import MAX_BUFFER
import time

class CiscoAsaSSH(SSHConnection):

    def __init__(self, ip, username, password, secret='', port=22, device_type='', verbose=True):

        self.ip = ip
        self.port = port
        self.username = username
        self.password = password
        self.secret = secret
        self.device_type = device_type

        if not verbose:
            self.establish_connection(verbose=False)
        else:
            self.establish_connection()

        # ASA must go into enable mode to disable_paging
        self.enable()
        self.disable_paging()
        self.find_prompt()


    def disable_paging(self, delay_factor=1):
        '''
        Cisco ASA paging disable 
        Ensures that multi-page output doesn't prompt for user interaction 
        (i.e. --MORE--)

        Must manually control the channel at this point.
        '''

        # ASA disables paging from configuration mode
        self.remote_conn.send("config term\n")
        time.sleep(1*delay_factor)
        self.remote_conn.send("pager 0\n")
        time.sleep(1*delay_factor)
        self.remote_conn.send("end\n")
        time.sleep(1*delay_factor)

        output = self.remote_conn.recv(MAX_BUFFER)

        return output


    def restore_paging(self):
        '''
        A paging requires a configuration change i.e. it is retained
        Restore the default paging after execution
        '''

        # Reset paging to 'pager 24' for ASA
        return self.send_config_set(['pager 24'])


    def enable(self, delay_factor=1):
        '''
        Enter enable mode

        Must manually control the channel at this point for ASA
        '''

        self.clear_buffer()
        self.remote_conn.send("\nenable\n")
        time.sleep(1*delay_factor)

        output = self.remote_conn.recv(MAX_BUFFER)
        if 'assword' in output:
            self.remote_conn.send(self.secret+'\n')
            self.remote_conn.send('\n')
            time.sleep(1*delay_factor)
            output += self.remote_conn.recv(MAX_BUFFER)

        return None


    def cleanup(self):
        '''
        Any needed cleanup before closing connection
        '''
        return self.restore_paging()<commit_msg>Don't go into config mode to disable paging on ASA, FIXES #3<commit_after>from netmiko.ssh_connection import SSHConnection
from netmiko.netmiko_globals import MAX_BUFFER
import time

class CiscoAsaSSH(SSHConnection):

    def __init__(self, ip, username, password, secret='', port=22, device_type='', verbose=True):

        self.ip = ip
        self.port = port
        self.username = username
        self.password = password
        self.secret = secret
        self.device_type = device_type

        if not verbose:
            self.establish_connection(verbose=False)
        else:
            self.establish_connection()

        # ASA must go into enable mode to disable_paging
        self.enable()
        self.disable_paging()
        self.find_prompt()


    def disable_paging(self, delay_factor=1):
        '''
        Cisco ASA paging disable 
        Ensures that multi-page output doesn't prompt for user interaction 
        (i.e. --MORE--)

        Must manually control the channel at this point.
        '''

        self.remote_conn.send("terminal pager 0\n")
        time.sleep(1*delay_factor)

        output = self.remote_conn.recv(MAX_BUFFER)

        return output


    def enable(self, delay_factor=1):
        '''
        Enter enable mode

        Must manually control the channel at this point for ASA
        '''

        self.clear_buffer()
        self.remote_conn.send("\nenable\n")
        time.sleep(1*delay_factor)

        output = self.remote_conn.recv(MAX_BUFFER)
        if 'assword' in output:
            self.remote_conn.send(self.secret+'\n')
            self.remote_conn.send('\n')
            time.sleep(1*delay_factor)
            output += self.remote_conn.recv(MAX_BUFFER)

        return None

{'fraction_non_alphanumeric': 0.09088669950738916, 'fraction_numerical': 0.005665024630541872, 'mean_word_length': 2.177621283255086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5604839', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1131, 'n_words': 290}