Checks if the device is in configuration mode or not.

        Cisco IOS devices abbreviate the prompt at 20 chars in config mode
19141
def check_config_mode(self, check_string=")#", pattern=""):
        
        return super(CiscoBaseConnection, self).check_config_mode(
            check_string=check_string, pattern=pattern
        )
169889
def display_config(self):
        

        if self.opt['Verbose']:
            hdrtxt = type(self).hdrtxt()
            # Call utility function to construct status display formatting
            self.hdrstr, self.fmtstr, self.nsep = common.solve_status_str(
                hdrtxt, fwdth0=type(self).fwiter, fprec=type(self).fpothr)
        else:
            self.hdrstr, self.fmtstr, self.nsep = '', '', 0
408231
private boolean isPluginConfiguration(Configuration configuration) {
		return (configuration.containsKey(ID_KEY) && getPluginId() == configuration.getInt(ID_KEY))
				// To keep backwards compatibility check also the classname
				|| getClass().getCanonicalName().equals(configuration.getString(CLASSNAME_KEY, ""));
	}
1252888
def check_config_mode(self, check_string=")#", pattern=r"[#\$]"):
        
        self.write_channel(self.RETURN)
        output = self.read_until_pattern(pattern=pattern)
        # Strip out (admin) so we don't get a false positive with (admin)#
        # (admin-config)# would still match.
        output = output.replace("(admin)", "")
        return check_string in output
1330206
def config_md5(self, source_config):
        """"""
        file_contents = source_config + "\n"  # Cisco IOS automatically adds this
        file_contents = file_contents.encode("UTF-8")
        return hashlib.md5(file_contents).hexdigest()
712350
def validate(config):
    '''
    
    '''

    VALID_ITEMS = [
        'type', 'bytes_sent', 'bytes_recv', 'packets_sent',
        'packets_recv', 'errin', 'errout', 'dropin',
        'dropout'
    ]

    # Configuration for load beacon should be a list of dicts
    if not isinstance(config, list):
        return False, ('Configuration for network_info beacon must be a list.')
    else:

        _config = {}
        list(map(_config.update, config))

        for item in _config.get('interfaces', {}):
            if not isinstance(_config['interfaces'][item], dict):
                return False, ('Configuration for network_info beacon must '
                               'be a list of dictionaries.')
            else:
                if not any(j in VALID_ITEMS for j in _config['interfaces'][item]):
                    return False, ('Invalid configuration item in '
                                   'Beacon configuration.')
    return True, 'Valid beacon configuration'
555481
def turn_on(host, did, token=None):
    """"""
    urllib3.disable_warnings()
    if token:
        scheme = "https"
    if not token:
        scheme = "http"
        token = "1234567890"
    url = (
            scheme + '://' + host + '/gwr/gop.php?cmd=DeviceSendCommand&data=<gip><version>1</version><token>' + token + '</token><did>' + did + '</did><value>1</value></gip>&fmt=xml')
    response = requests.get(url, verify=False)
    if response.status_code == '200':
        return True
    else:
        return False
486478
function (message, config, cb) {
        if(typeof config === 'function') {
            cb = config;
            config = {};
        }
        var stdin = config.stdin || process.stdin,
            stdout = config.stdout || process.stdout,
            prompt = config.prompt || '\u203A';
        stdout.write('  ' + message + '\n  ' + prompt + ' ');
        stdin.resume();
        stdin.setEncoding('utf8');
        stdin.on('data', function (text) {
            text = text.trim().replace(/\r\n|\n/, '');
            cb(text);
        });
    }
888742
def check_configuration(config):
    '''
    '''
    sections = ('commands', 'parameters', 'pipelines')
    # Check all sections are there and contain dicts
    for section in sections:
        if section not in config:
            error_msg = 'Error: Section {0} is missing.'.format(section)
            raise ConfigurationErrorDietException(error_msg)
        if not isinstance(config[section], dict):
            error_msg = 'Error: Section {0} is malformed.'.format(section)
            raise ConfigurationErrorDietException(error_msg)

    # Check every command has a corresponding parameters entry
    commands_cmds = set(list(config['commands'].keys()))
    parameters_cmds = set(list(config['parameters'].keys()))
    if commands_cmds != parameters_cmds:
        error_msg = ('Every command in commands and parameters section has to '
                     'have a corresponding entry in the other section.')
        raise ConfigurationErrorDietException(error_msg)

    # Check pipelines section contains lists as values and each of them only
    # has entries listed in commands section
    for cmd in config['pipelines']:
        pipeline = config['pipelines'][cmd]
        if not isinstance(pipeline, list):
            error_msg = ('Error: Pipeline {0} is malformed. Values have to '
                         'be a list of command names.').format(cmd)
            raise ConfigurationErrorDietException(error_msg)
        for tool in pipeline:
            if tool not in commands_cmds:
                error_msg = ('Error in pipeline {0}. "{1}" cannot be found '
                             'among commands listed in commands '
                             'section').format(cmd, tool)
                raise ConfigurationErrorDietException(error_msg)
506710
def validate(config):
    '''
    
    '''
    _config = {}
    list(map(_config.update, config))

    if not isinstance(config, list):
        return False, ('Configuration for avahi_announce '
                       'beacon must be a list.')

    elif not all(x in _config for x in ('servicetype',
                                        'port',
                                        'txt')):
        return False, ('Configuration for avahi_announce beacon '
                       'must contain servicetype, port and txt items.')
    return True, 'Valid beacon configuration.'
58878
def compare_config(self):
        
        if self.ssh_connection is False:
            self._open_ssh()

        self.ssh_device.exit_config_mode()
        diff = self.ssh_device.send_command("show config diff")
        return diff.strip()
583405
def prompt_4_mfa_serial(input = None):
    
    return prompt_4_value('Enter your MFA serial:', required = False, regex = re_mfa_serial_format, regex_format = mfa_serial_format, input = input)
508943
def check_config_mode(self, check_string=")#", pattern="#"):
        
        return super(CiscoIosBase, self).check_config_mode(
            check_string=check_string, pattern=pattern
        )
140433
def _write_config(self):
        
        normal_flag = False
        if self._mode == MODE_NORMAL:
            #Writes to the config register may be ignored while in Normal mode
            normal_flag = True
            self.mode = MODE_SLEEP #So we switch to Sleep mode first
        self._write_register_byte(_BME280_REGISTER_CONFIG, self._config)
        if normal_flag:
            self.mode = MODE_NORMAL
7625
private function _checkLayerConfig()
    {
        $errorString = array();
        if ($this->_providerID == '') {
            array_push($errorString, 'LAYER_PROVIDER_ID');
        }

        if ($this->_keyID == '') {
            array_push($errorString, 'LAYER_PRIVATE_KEY_ID');
        }

        if ($this->_privateKey == '') {
            array_push($errorString, 'LAYER_PRIVATE_KEY');
        }

        if (count($errorString) > 0) {
            $joined = implode(',', $errorString);
            trigger_error("$joined  not configured. See README.md", E_USER_ERROR);
        }
    }
1186615
def a_expected_prompt(ctx):
    """"""
    prompt = ctx.ctrl.match.group(0)
    ctx.device.update_driver(prompt)
    ctx.device.update_config_mode()
    ctx.device.update_hostname()
    ctx.finished = True
    return True
1029980
def save_config(self, cmd="write mem", confirm=False, confirm_response=""):
        """"""
        return super(CiscoIosBase, self).save_config(
            cmd=cmd, confirm=confirm, confirm_response=confirm_response
        )