Coverage for rancidcmd : 96%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*-
"""Class RancidCmd.
Attributes:
:login (str): RANCID login command(clogin, jlogin, etc). :user (str): Login username. :password (str): Login password. :address (str): Host name or ip address. :enable_password (str, optional): Enable password for clogin. Default is None. :option(int, optional): Option example: '-d -x "commands.txt"'. Default is None. :encoding(str, optional): Encoding type. Default is 'utf-8'.
Using example:
* Please see README. https://github.com/mtoshi/rancidcmd/blob/master/README.rst
* Sample code. https://github.com/mtoshi/rancidcmd/blob/master/samples/sample.py
"""
"""Constructor.
Args:
:login (str): RANCID login command(clogin, jlogin, etc). :user (str): Login username. :password (str): Login password. :address (str): Host name or ip address. :enable_password (str, optional): Enable password for clogin. Default is None. :option(int, optional): Option example: '-d -x "commands.txt"'. Default is None. :encoding(str, optional): Encoding type. Default is 'utf-8'.
""" u'native_cloginrc_path', self.default_native_cloginrc_path)
"""Check -x option.
"-c" gets commands from command-line. "-x" gets commnads from file.
These are for command option and exclusive. If "-x" option is specified, then "-c" command is ignored. """
"""Generate command.
Args:
:command (str): Example is "show version".
Returns:
:str: Return the command string.
If there is the "enable_password". ::
'xlogin -u admin -c "show version"'
""" else:
"""Change string with encoding setting.
Args:
:byte_data (bytes): Popen output.
"""
"""Login and command execution.
Args:
:command (str): Command for execution.
Returns:
:dict: Example is below. ::
{ 'std_err': '', 'std_out': '', 'rtn_code': '', } """ shell=True, env=env, stdout=PIPE, stderr=PIPE) 'std_err': self.decode_bytes(std_err), 'rtn_code': rtn_code}
"""cloginrc string check.
Returns:
:str: Return cloginrc config string. """
"""Execute command string check.
Args:
:command (str): Example is "show version".
Returns:
:str: Return the command string. """
"""Command execution.
Args:
:command (str): Example is "show version".
Returns:
:dict: Example is below. ::
{ 'std_err': '', 'std_out': '', 'rtn_code': '', }
"""
def get_home_path(): """Get home directory path. Returns: :str: User home directory path. """
"""Check rancid settings file.
Note:
If RANCID settings file is not exists, then make temporary settings file.
Returns:
:NamedTemporaryFile: RANCID settings tempfile object.
"""
host=host, user=user)
host=host, method=method, port=port)
host=host, passwd=passwd, epasswd=epasswd) else: host=host, passwd=passwd)
"""Check native settings file. Note: If RANCID settings file is not exists or empty, then make temporary cloginrc file. So this method is for check cloginrc file.
Returns: :str: RANCID settings file text. """ if os.path.getsize(path) == 0: return None with open(path, u'r') as _file: return _file.read()
"""Make native settings file.""" |