partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | F5TmshSSH.session_preparation | Prepare the session after the connection has been established. | netmiko/f5/f5_tmsh_ssh.py | def session_preparation(self):
"""Prepare the session after the connection has been established."""
self._test_channel_read()
self.set_base_prompt()
self.tmsh_mode()
self.set_base_prompt()
self.disable_paging(
command="modify cli preference pager disabled disp... | def session_preparation(self):
"""Prepare the session after the connection has been established."""
self._test_channel_read()
self.set_base_prompt()
self.tmsh_mode()
self.set_base_prompt()
self.disable_paging(
command="modify cli preference pager disabled disp... | [
"Prepare",
"the",
"session",
"after",
"the",
"connection",
"has",
"been",
"established",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/f5/f5_tmsh_ssh.py#L7-L18 | [
"def",
"session_preparation",
"(",
"self",
")",
":",
"self",
".",
"_test_channel_read",
"(",
")",
"self",
".",
"set_base_prompt",
"(",
")",
"self",
".",
"tmsh_mode",
"(",
")",
"self",
".",
"set_base_prompt",
"(",
")",
"self",
".",
"disable_paging",
"(",
"c... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | F5TmshSSH.tmsh_mode | tmsh command is equivalent to config command on F5. | netmiko/f5/f5_tmsh_ssh.py | def tmsh_mode(self, delay_factor=1):
"""tmsh command is equivalent to config command on F5."""
delay_factor = self.select_delay_factor(delay_factor)
self.clear_buffer()
command = "{}tmsh{}".format(self.RETURN, self.RETURN)
self.write_channel(command)
time.sleep(1 * delay_... | def tmsh_mode(self, delay_factor=1):
"""tmsh command is equivalent to config command on F5."""
delay_factor = self.select_delay_factor(delay_factor)
self.clear_buffer()
command = "{}tmsh{}".format(self.RETURN, self.RETURN)
self.write_channel(command)
time.sleep(1 * delay_... | [
"tmsh",
"command",
"is",
"equivalent",
"to",
"config",
"command",
"on",
"F5",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/f5/f5_tmsh_ssh.py#L20-L28 | [
"def",
"tmsh_mode",
"(",
"self",
",",
"delay_factor",
"=",
"1",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
")",
"self",
".",
"clear_buffer",
"(",
")",
"command",
"=",
"\"{}tmsh{}\"",
".",
"format",
"(",
"self",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | LinuxSSH.set_base_prompt | Determine base prompt. | netmiko/linux/linux_ssh.py | def set_base_prompt(
self, pri_prompt_terminator="$", alt_prompt_terminator="#", delay_factor=1
):
"""Determine base prompt."""
return super(LinuxSSH, self).set_base_prompt(
pri_prompt_terminator=pri_prompt_terminator,
alt_prompt_terminator=alt_prompt_terminator,
... | def set_base_prompt(
self, pri_prompt_terminator="$", alt_prompt_terminator="#", delay_factor=1
):
"""Determine base prompt."""
return super(LinuxSSH, self).set_base_prompt(
pri_prompt_terminator=pri_prompt_terminator,
alt_prompt_terminator=alt_prompt_terminator,
... | [
"Determine",
"base",
"prompt",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/linux/linux_ssh.py#L30-L38 | [
"def",
"set_base_prompt",
"(",
"self",
",",
"pri_prompt_terminator",
"=",
"\"$\"",
",",
"alt_prompt_terminator",
"=",
"\"#\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"return",
"super",
"(",
"LinuxSSH",
",",
"self",
")",
".",
"set_base_prompt",
"(",
"pri_prom... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | LinuxSSH.send_config_set | Can't exit from root (if root) | netmiko/linux/linux_ssh.py | def send_config_set(self, config_commands=None, exit_config_mode=True, **kwargs):
"""Can't exit from root (if root)"""
if self.username == "root":
exit_config_mode = False
return super(LinuxSSH, self).send_config_set(
config_commands=config_commands, exit_config_mode=exit... | def send_config_set(self, config_commands=None, exit_config_mode=True, **kwargs):
"""Can't exit from root (if root)"""
if self.username == "root":
exit_config_mode = False
return super(LinuxSSH, self).send_config_set(
config_commands=config_commands, exit_config_mode=exit... | [
"Can",
"t",
"exit",
"from",
"root",
"(",
"if",
"root",
")"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/linux/linux_ssh.py#L40-L46 | [
"def",
"send_config_set",
"(",
"self",
",",
"config_commands",
"=",
"None",
",",
"exit_config_mode",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"username",
"==",
"\"root\"",
":",
"exit_config_mode",
"=",
"False",
"return",
"super",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | LinuxSSH.exit_enable_mode | Exit enable mode. | netmiko/linux/linux_ssh.py | def exit_enable_mode(self, exit_command="exit"):
"""Exit enable mode."""
delay_factor = self.select_delay_factor(delay_factor=0)
output = ""
if self.check_enable_mode():
self.write_channel(self.normalize_cmd(exit_command))
time.sleep(0.3 * delay_factor)
... | def exit_enable_mode(self, exit_command="exit"):
"""Exit enable mode."""
delay_factor = self.select_delay_factor(delay_factor=0)
output = ""
if self.check_enable_mode():
self.write_channel(self.normalize_cmd(exit_command))
time.sleep(0.3 * delay_factor)
... | [
"Exit",
"enable",
"mode",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/linux/linux_ssh.py#L63-L73 | [
"def",
"exit_enable_mode",
"(",
"self",
",",
"exit_command",
"=",
"\"exit\"",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
"=",
"0",
")",
"output",
"=",
"\"\"",
"if",
"self",
".",
"check_enable_mode",
"(",
")",
":",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | LinuxSSH.enable | Attempt to become root. | netmiko/linux/linux_ssh.py | def enable(self, cmd="sudo su", pattern="ssword", re_flags=re.IGNORECASE):
"""Attempt to become root."""
delay_factor = self.select_delay_factor(delay_factor=0)
output = ""
if not self.check_enable_mode():
self.write_channel(self.normalize_cmd(cmd))
time.sleep(0.3... | def enable(self, cmd="sudo su", pattern="ssword", re_flags=re.IGNORECASE):
"""Attempt to become root."""
delay_factor = self.select_delay_factor(delay_factor=0)
output = ""
if not self.check_enable_mode():
self.write_channel(self.normalize_cmd(cmd))
time.sleep(0.3... | [
"Attempt",
"to",
"become",
"root",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/linux/linux_ssh.py#L75-L97 | [
"def",
"enable",
"(",
"self",
",",
"cmd",
"=",
"\"sudo su\"",
",",
"pattern",
"=",
"\"ssword\"",
",",
"re_flags",
"=",
"re",
".",
"IGNORECASE",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
"=",
"0",
")",
"output",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | LinuxFileTransfer.remote_file_size | Get the file size of the remote file. | netmiko/linux/linux_ssh.py | def remote_file_size(self, remote_cmd="", remote_file=None):
"""Get the file size of the remote file."""
return self._remote_file_size_unix(
remote_cmd=remote_cmd, remote_file=remote_file
) | def remote_file_size(self, remote_cmd="", remote_file=None):
"""Get the file size of the remote file."""
return self._remote_file_size_unix(
remote_cmd=remote_cmd, remote_file=remote_file
) | [
"Get",
"the",
"file",
"size",
"of",
"the",
"remote",
"file",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/linux/linux_ssh.py#L135-L139 | [
"def",
"remote_file_size",
"(",
"self",
",",
"remote_cmd",
"=",
"\"\"",
",",
"remote_file",
"=",
"None",
")",
":",
"return",
"self",
".",
"_remote_file_size_unix",
"(",
"remote_cmd",
"=",
"remote_cmd",
",",
"remote_file",
"=",
"remote_file",
")"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | file_transfer | Use Secure Copy or Inline (IOS-only) to transfer files to/from network devices.
inline_transfer ONLY SUPPORTS TEXT FILES and will not support binary file transfers.
return {
'file_exists': boolean,
'file_transferred': boolean,
'file_verified': boolean,
} | netmiko/scp_functions.py | def file_transfer(
ssh_conn,
source_file,
dest_file,
file_system=None,
direction="put",
disable_md5=False,
inline_transfer=False,
overwrite_file=False,
):
"""Use Secure Copy or Inline (IOS-only) to transfer files to/from network devices.
inline_transfer ONLY SUPPORTS TEXT FILES ... | def file_transfer(
ssh_conn,
source_file,
dest_file,
file_system=None,
direction="put",
disable_md5=False,
inline_transfer=False,
overwrite_file=False,
):
"""Use Secure Copy or Inline (IOS-only) to transfer files to/from network devices.
inline_transfer ONLY SUPPORTS TEXT FILES ... | [
"Use",
"Secure",
"Copy",
"or",
"Inline",
"(",
"IOS",
"-",
"only",
")",
"to",
"transfer",
"files",
"to",
"/",
"from",
"network",
"devices",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/scp_functions.py#L23-L112 | [
"def",
"file_transfer",
"(",
"ssh_conn",
",",
"source_file",
",",
"dest_file",
",",
"file_system",
"=",
"None",
",",
"direction",
"=",
"\"put\"",
",",
"disable_md5",
"=",
"False",
",",
"inline_transfer",
"=",
"False",
",",
"overwrite_file",
"=",
"False",
",",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | AlcatelSrosSSH.set_base_prompt | Remove the > when navigating into the different config level. | netmiko/alcatel/alcatel_sros_ssh.py | def set_base_prompt(self, *args, **kwargs):
"""Remove the > when navigating into the different config level."""
cur_base_prompt = super(AlcatelSrosSSH, self).set_base_prompt(*args, **kwargs)
match = re.search(r"(.*)(>.*)*#", cur_base_prompt)
if match:
# strip off >... from ba... | def set_base_prompt(self, *args, **kwargs):
"""Remove the > when navigating into the different config level."""
cur_base_prompt = super(AlcatelSrosSSH, self).set_base_prompt(*args, **kwargs)
match = re.search(r"(.*)(>.*)*#", cur_base_prompt)
if match:
# strip off >... from ba... | [
"Remove",
"the",
">",
"when",
"navigating",
"into",
"the",
"different",
"config",
"level",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/alcatel/alcatel_sros_ssh.py#L20-L27 | [
"def",
"set_base_prompt",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cur_base_prompt",
"=",
"super",
"(",
"AlcatelSrosSSH",
",",
"self",
")",
".",
"set_base_prompt",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"match",
"=",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | AlcatelSrosSSH.enable | Enter enable mode. | netmiko/alcatel/alcatel_sros_ssh.py | def enable(self, cmd="enable-admin", pattern="ssword", re_flags=re.IGNORECASE):
"""Enter enable mode."""
return super(AlcatelSrosSSH, self).enable(
cmd=cmd, pattern=pattern, re_flags=re_flags
) | def enable(self, cmd="enable-admin", pattern="ssword", re_flags=re.IGNORECASE):
"""Enter enable mode."""
return super(AlcatelSrosSSH, self).enable(
cmd=cmd, pattern=pattern, re_flags=re_flags
) | [
"Enter",
"enable",
"mode",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/alcatel/alcatel_sros_ssh.py#L29-L33 | [
"def",
"enable",
"(",
"self",
",",
"cmd",
"=",
"\"enable-admin\"",
",",
"pattern",
"=",
"\"ssword\"",
",",
"re_flags",
"=",
"re",
".",
"IGNORECASE",
")",
":",
"return",
"super",
"(",
"AlcatelSrosSSH",
",",
"self",
")",
".",
"enable",
"(",
"cmd",
"=",
"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | AlcatelSrosSSH.check_enable_mode | Check whether we are in enable-admin mode.
SROS requires us to do this:
*A:HOSTNAME# enable-admin
MINOR: CLI Already in admin mode.
*A:HOSTNAME#
*A:HOSTNAME# enable-admin
Password:
MINOR: CLI Invalid password.
*A:HOSTNAME# | netmiko/alcatel/alcatel_sros_ssh.py | def check_enable_mode(self, check_string="CLI Already in admin mode"):
"""Check whether we are in enable-admin mode.
SROS requires us to do this:
*A:HOSTNAME# enable-admin
MINOR: CLI Already in admin mode.
*A:HOSTNAME#
*A:HOSTNAME# enable-admin
Password:
... | def check_enable_mode(self, check_string="CLI Already in admin mode"):
"""Check whether we are in enable-admin mode.
SROS requires us to do this:
*A:HOSTNAME# enable-admin
MINOR: CLI Already in admin mode.
*A:HOSTNAME#
*A:HOSTNAME# enable-admin
Password:
... | [
"Check",
"whether",
"we",
"are",
"in",
"enable",
"-",
"admin",
"mode",
".",
"SROS",
"requires",
"us",
"to",
"do",
"this",
":",
"*",
"A",
":",
"HOSTNAME#",
"enable",
"-",
"admin",
"MINOR",
":",
"CLI",
"Already",
"in",
"admin",
"mode",
".",
"*",
"A",
... | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/alcatel/alcatel_sros_ssh.py#L35-L54 | [
"def",
"check_enable_mode",
"(",
"self",
",",
"check_string",
"=",
"\"CLI Already in admin mode\"",
")",
":",
"output",
"=",
"self",
".",
"send_command_timing",
"(",
"\"enable-admin\"",
")",
"if",
"re",
".",
"search",
"(",
"r\"ssword\"",
",",
"output",
")",
":",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | AlcatelSrosSSH.config_mode | Enter into configuration mode on SROS device. | netmiko/alcatel/alcatel_sros_ssh.py | def config_mode(self, config_command="configure", pattern="#"):
""" Enter into configuration mode on SROS device."""
return super(AlcatelSrosSSH, self).config_mode(
config_command=config_command, pattern=pattern
) | def config_mode(self, config_command="configure", pattern="#"):
""" Enter into configuration mode on SROS device."""
return super(AlcatelSrosSSH, self).config_mode(
config_command=config_command, pattern=pattern
) | [
"Enter",
"into",
"configuration",
"mode",
"on",
"SROS",
"device",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/alcatel/alcatel_sros_ssh.py#L60-L64 | [
"def",
"config_mode",
"(",
"self",
",",
"config_command",
"=",
"\"configure\"",
",",
"pattern",
"=",
"\"#\"",
")",
":",
"return",
"super",
"(",
"AlcatelSrosSSH",
",",
"self",
")",
".",
"config_mode",
"(",
"config_command",
"=",
"config_command",
",",
"pattern"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | AlcatelSrosSSH.exit_config_mode | Exit from configuration mode. | netmiko/alcatel/alcatel_sros_ssh.py | def exit_config_mode(self, exit_config="exit all", pattern="#"):
""" Exit from configuration mode."""
return super(AlcatelSrosSSH, self).exit_config_mode(
exit_config=exit_config, pattern=pattern
) | def exit_config_mode(self, exit_config="exit all", pattern="#"):
""" Exit from configuration mode."""
return super(AlcatelSrosSSH, self).exit_config_mode(
exit_config=exit_config, pattern=pattern
) | [
"Exit",
"from",
"configuration",
"mode",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/alcatel/alcatel_sros_ssh.py#L66-L70 | [
"def",
"exit_config_mode",
"(",
"self",
",",
"exit_config",
"=",
"\"exit all\"",
",",
"pattern",
"=",
"\"#\"",
")",
":",
"return",
"super",
"(",
"AlcatelSrosSSH",
",",
"self",
")",
".",
"exit_config_mode",
"(",
"exit_config",
"=",
"exit_config",
",",
"pattern"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | AlcatelSrosSSH.check_config_mode | Checks if the device is in configuration mode or not. | netmiko/alcatel/alcatel_sros_ssh.py | def check_config_mode(self, check_string="config", pattern="#"):
""" Checks if the device is in configuration mode or not. """
return super(AlcatelSrosSSH, self).check_config_mode(
check_string=check_string, pattern=pattern
) | def check_config_mode(self, check_string="config", pattern="#"):
""" Checks if the device is in configuration mode or not. """
return super(AlcatelSrosSSH, self).check_config_mode(
check_string=check_string, pattern=pattern
) | [
"Checks",
"if",
"the",
"device",
"is",
"in",
"configuration",
"mode",
"or",
"not",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/alcatel/alcatel_sros_ssh.py#L72-L76 | [
"def",
"check_config_mode",
"(",
"self",
",",
"check_string",
"=",
"\"config\"",
",",
"pattern",
"=",
"\"#\"",
")",
":",
"return",
"super",
"(",
"AlcatelSrosSSH",
",",
"self",
")",
".",
"check_config_mode",
"(",
"check_string",
"=",
"check_string",
",",
"patte... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | DellDNOS6Base.save_config | Saves Config | netmiko/dell/dell_dnos6.py | def save_config(
self,
cmd="copy running-configuration startup-configuration",
confirm=False,
confirm_response="",
):
"""Saves Config"""
return super(DellDNOS6Base, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | def save_config(
self,
cmd="copy running-configuration startup-configuration",
confirm=False,
confirm_response="",
):
"""Saves Config"""
return super(DellDNOS6Base, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"Saves",
"Config"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/dell/dell_dnos6.py#L20-L29 | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"copy running-configuration startup-configuration\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
",",
")",
":",
"return",
"super",
"(",
"DellDNOS6Base",
",",
"self",
")",
".",
"save_c... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | ExtremeExosBase.set_base_prompt | Extreme attaches an id to the prompt. The id increases with every command.
It needs to br stripped off to match the prompt. Eg.
testhost.1 #
testhost.2 #
testhost.3 #
If new config is loaded and not saved yet, a '* ' prefix appears before the
prompt, eg.
... | netmiko/extreme/extreme_exos.py | def set_base_prompt(self, *args, **kwargs):
"""
Extreme attaches an id to the prompt. The id increases with every command.
It needs to br stripped off to match the prompt. Eg.
testhost.1 #
testhost.2 #
testhost.3 #
If new config is loaded and not sav... | def set_base_prompt(self, *args, **kwargs):
"""
Extreme attaches an id to the prompt. The id increases with every command.
It needs to br stripped off to match the prompt. Eg.
testhost.1 #
testhost.2 #
testhost.3 #
If new config is loaded and not sav... | [
"Extreme",
"attaches",
"an",
"id",
"to",
"the",
"prompt",
".",
"The",
"id",
"increases",
"with",
"every",
"command",
".",
"It",
"needs",
"to",
"br",
"stripped",
"off",
"to",
"match",
"the",
"prompt",
".",
"Eg",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_exos.py#L23-L45 | [
"def",
"set_base_prompt",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cur_base_prompt",
"=",
"super",
"(",
"ExtremeExosBase",
",",
"self",
")",
".",
"set_base_prompt",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"# Strip off an... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | ExtremeExosBase.send_command | Extreme needs special handler here due to the prompt changes. | netmiko/extreme/extreme_exos.py | def send_command(self, *args, **kwargs):
"""Extreme needs special handler here due to the prompt changes."""
# Change send_command behavior to use self.base_prompt
kwargs.setdefault("auto_find_prompt", False)
# refresh self.base_prompt
self.set_base_prompt()
return supe... | def send_command(self, *args, **kwargs):
"""Extreme needs special handler here due to the prompt changes."""
# Change send_command behavior to use self.base_prompt
kwargs.setdefault("auto_find_prompt", False)
# refresh self.base_prompt
self.set_base_prompt()
return supe... | [
"Extreme",
"needs",
"special",
"handler",
"here",
"due",
"to",
"the",
"prompt",
"changes",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_exos.py#L47-L55 | [
"def",
"send_command",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Change send_command behavior to use self.base_prompt",
"kwargs",
".",
"setdefault",
"(",
"\"auto_find_prompt\"",
",",
"False",
")",
"# refresh self.base_prompt",
"self",
".",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | ExtremeExosBase.save_config | Saves configuration. | netmiko/extreme/extreme_exos.py | def save_config(
self, cmd="save configuration primary", confirm=False, confirm_response=""
):
"""Saves configuration."""
return super(ExtremeExosBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | def save_config(
self, cmd="save configuration primary", confirm=False, confirm_response=""
):
"""Saves configuration."""
return super(ExtremeExosBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"Saves",
"configuration",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_exos.py#L69-L75 | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"save configuration primary\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"ExtremeExosBase",
",",
"self",
")",
".",
"save_config",
"(",
"cmd",
"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | JuniperBase.enter_cli_mode | Check if at shell prompt root@ and go into CLI. | netmiko/juniper/juniper.py | def enter_cli_mode(self):
"""Check if at shell prompt root@ and go into CLI."""
delay_factor = self.select_delay_factor(delay_factor=0)
count = 0
cur_prompt = ""
while count < 50:
self.write_channel(self.RETURN)
time.sleep(0.1 * delay_factor)
c... | def enter_cli_mode(self):
"""Check if at shell prompt root@ and go into CLI."""
delay_factor = self.select_delay_factor(delay_factor=0)
count = 0
cur_prompt = ""
while count < 50:
self.write_channel(self.RETURN)
time.sleep(0.1 * delay_factor)
c... | [
"Check",
"if",
"at",
"shell",
"prompt",
"root"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/juniper/juniper.py#L43-L59 | [
"def",
"enter_cli_mode",
"(",
"self",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
"=",
"0",
")",
"count",
"=",
"0",
"cur_prompt",
"=",
"\"\"",
"while",
"count",
"<",
"50",
":",
"self",
".",
"write_channel",
"(",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | JuniperBase.strip_prompt | Strip the trailing router prompt from the output. | netmiko/juniper/juniper.py | def strip_prompt(self, *args, **kwargs):
"""Strip the trailing router prompt from the output."""
a_string = super(JuniperBase, self).strip_prompt(*args, **kwargs)
return self.strip_context_items(a_string) | def strip_prompt(self, *args, **kwargs):
"""Strip the trailing router prompt from the output."""
a_string = super(JuniperBase, self).strip_prompt(*args, **kwargs)
return self.strip_context_items(a_string) | [
"Strip",
"the",
"trailing",
"router",
"prompt",
"from",
"the",
"output",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/juniper/juniper.py#L187-L190 | [
"def",
"strip_prompt",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"a_string",
"=",
"super",
"(",
"JuniperBase",
",",
"self",
")",
".",
"strip_prompt",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"st... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | JuniperBase.strip_context_items | Strip Juniper-specific output.
Juniper will also put a configuration context:
[edit]
and various chassis contexts:
{master:0}, {backup:1}
This method removes those lines. | netmiko/juniper/juniper.py | def strip_context_items(self, a_string):
"""Strip Juniper-specific output.
Juniper will also put a configuration context:
[edit]
and various chassis contexts:
{master:0}, {backup:1}
This method removes those lines.
"""
strings_to_strip = [
r... | def strip_context_items(self, a_string):
"""Strip Juniper-specific output.
Juniper will also put a configuration context:
[edit]
and various chassis contexts:
{master:0}, {backup:1}
This method removes those lines.
"""
strings_to_strip = [
r... | [
"Strip",
"Juniper",
"-",
"specific",
"output",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/juniper/juniper.py#L192-L218 | [
"def",
"strip_context_items",
"(",
"self",
",",
"a_string",
")",
":",
"strings_to_strip",
"=",
"[",
"r\"\\[edit.*\\]\"",
",",
"r\"\\{master:.*\\}\"",
",",
"r\"\\{backup:.*\\}\"",
",",
"r\"\\{line.*\\}\"",
",",
"r\"\\{primary.*\\}\"",
",",
"r\"\\{secondary.*\\}\"",
",",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | AristaBase.check_config_mode | Checks if the device is in configuration mode or not.
Arista, unfortunately, does this:
loc1-core01(s1)#
Can also be (s2) | netmiko/arista/arista.py | def check_config_mode(self, check_string=")#", pattern=""):
"""
Checks if the device is in configuration mode or not.
Arista, unfortunately, does this:
loc1-core01(s1)#
Can also be (s2)
"""
log.debug("pattern: {0}".format(pattern))
self.write_channel(sel... | def check_config_mode(self, check_string=")#", pattern=""):
"""
Checks if the device is in configuration mode or not.
Arista, unfortunately, does this:
loc1-core01(s1)#
Can also be (s2)
"""
log.debug("pattern: {0}".format(pattern))
self.write_channel(sel... | [
"Checks",
"if",
"the",
"device",
"is",
"in",
"configuration",
"mode",
"or",
"not",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/arista/arista.py#L19-L35 | [
"def",
"check_config_mode",
"(",
"self",
",",
"check_string",
"=",
"\")#\"",
",",
"pattern",
"=",
"\"\"",
")",
":",
"log",
".",
"debug",
"(",
"\"pattern: {0}\"",
".",
"format",
"(",
"pattern",
")",
")",
"self",
".",
"write_channel",
"(",
"self",
".",
"RE... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoNxosSSH.session_preparation | Prepare the session after the connection has been established. | netmiko/cisco/cisco_nxos_ssh.py | def session_preparation(self):
"""Prepare the session after the connection has been established."""
self._test_channel_read(pattern=r"[>#]")
self.ansi_escape_codes = True
self.set_base_prompt()
self.disable_paging()
# Clear the read buffer
time.sleep(0.3 * self.gl... | def session_preparation(self):
"""Prepare the session after the connection has been established."""
self._test_channel_read(pattern=r"[>#]")
self.ansi_escape_codes = True
self.set_base_prompt()
self.disable_paging()
# Clear the read buffer
time.sleep(0.3 * self.gl... | [
"Prepare",
"the",
"session",
"after",
"the",
"connection",
"has",
"been",
"established",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_nxos_ssh.py#L11-L19 | [
"def",
"session_preparation",
"(",
"self",
")",
":",
"self",
".",
"_test_channel_read",
"(",
"pattern",
"=",
"r\"[>#]\"",
")",
"self",
".",
"ansi_escape_codes",
"=",
"True",
"self",
".",
"set_base_prompt",
"(",
")",
"self",
".",
"disable_paging",
"(",
")",
"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoNxosSSH.normalize_linefeeds | Convert '\r\n' or '\r\r\n' to '\n, and remove extra '\r's in the text. | netmiko/cisco/cisco_nxos_ssh.py | def normalize_linefeeds(self, a_string):
"""Convert '\r\n' or '\r\r\n' to '\n, and remove extra '\r's in the text."""
newline = re.compile(r"(\r\r\n|\r\n)")
# NX-OS fix for incorrect MD5 on 9K (due to strange <enter> patterns on NX-OS)
return newline.sub(self.RESPONSE_RETURN, a_string).r... | def normalize_linefeeds(self, a_string):
"""Convert '\r\n' or '\r\r\n' to '\n, and remove extra '\r's in the text."""
newline = re.compile(r"(\r\r\n|\r\n)")
# NX-OS fix for incorrect MD5 on 9K (due to strange <enter> patterns on NX-OS)
return newline.sub(self.RESPONSE_RETURN, a_string).r... | [
"Convert",
"\\",
"r",
"\\",
"n",
"or",
"\\",
"r",
"\\",
"r",
"\\",
"n",
"to",
"\\",
"n",
"and",
"remove",
"extra",
"\\",
"r",
"s",
"in",
"the",
"text",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_nxos_ssh.py#L21-L25 | [
"def",
"normalize_linefeeds",
"(",
"self",
",",
"a_string",
")",
":",
"newline",
"=",
"re",
".",
"compile",
"(",
"r\"(\\r\\r\\n|\\r\\n)\"",
")",
"# NX-OS fix for incorrect MD5 on 9K (due to strange <enter> patterns on NX-OS)",
"return",
"newline",
".",
"sub",
"(",
"self",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoNxosSSH.check_config_mode | Checks if the device is in configuration mode or not. | netmiko/cisco/cisco_nxos_ssh.py | def check_config_mode(self, check_string=")#", pattern="#"):
"""Checks if the device is in configuration mode or not."""
return super(CiscoNxosSSH, self).check_config_mode(
check_string=check_string, pattern=pattern
) | def check_config_mode(self, check_string=")#", pattern="#"):
"""Checks if the device is in configuration mode or not."""
return super(CiscoNxosSSH, self).check_config_mode(
check_string=check_string, pattern=pattern
) | [
"Checks",
"if",
"the",
"device",
"is",
"in",
"configuration",
"mode",
"or",
"not",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_nxos_ssh.py#L27-L31 | [
"def",
"check_config_mode",
"(",
"self",
",",
"check_string",
"=",
"\")#\"",
",",
"pattern",
"=",
"\"#\"",
")",
":",
"return",
"super",
"(",
"CiscoNxosSSH",
",",
"self",
")",
".",
"check_config_mode",
"(",
"check_string",
"=",
"check_string",
",",
"pattern",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoNxosFileTransfer.check_file_exists | Check if the dest_file already exists on the file system (return boolean). | netmiko/cisco/cisco_nxos_ssh.py | def check_file_exists(self, remote_cmd=""):
"""Check if the dest_file already exists on the file system (return boolean)."""
if self.direction == "put":
if not remote_cmd:
remote_cmd = "dir {}{}".format(self.file_system, self.dest_file)
remote_out = self.ssh_ctl_c... | def check_file_exists(self, remote_cmd=""):
"""Check if the dest_file already exists on the file system (return boolean)."""
if self.direction == "put":
if not remote_cmd:
remote_cmd = "dir {}{}".format(self.file_system, self.dest_file)
remote_out = self.ssh_ctl_c... | [
"Check",
"if",
"the",
"dest_file",
"already",
"exists",
"on",
"the",
"file",
"system",
"(",
"return",
"boolean",
")",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_nxos_ssh.py#L64-L78 | [
"def",
"check_file_exists",
"(",
"self",
",",
"remote_cmd",
"=",
"\"\"",
")",
":",
"if",
"self",
".",
"direction",
"==",
"\"put\"",
":",
"if",
"not",
"remote_cmd",
":",
"remote_cmd",
"=",
"\"dir {}{}\"",
".",
"format",
"(",
"self",
".",
"file_system",
",",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoTpTcCeSSH.strip_prompt | Strip the trailing router prompt from the output. | netmiko/cisco/cisco_tp_tcce.py | def strip_prompt(self, a_string):
"""Strip the trailing router prompt from the output."""
expect_string = r"^(OK|ERROR|Command not recognized\.)$"
response_list = a_string.split(self.RESPONSE_RETURN)
last_line = response_list[-1]
if re.search(expect_string, last_line):
... | def strip_prompt(self, a_string):
"""Strip the trailing router prompt from the output."""
expect_string = r"^(OK|ERROR|Command not recognized\.)$"
response_list = a_string.split(self.RESPONSE_RETURN)
last_line = response_list[-1]
if re.search(expect_string, last_line):
... | [
"Strip",
"the",
"trailing",
"router",
"prompt",
"from",
"the",
"output",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_tp_tcce.py#L53-L61 | [
"def",
"strip_prompt",
"(",
"self",
",",
"a_string",
")",
":",
"expect_string",
"=",
"r\"^(OK|ERROR|Command not recognized\\.)$\"",
"response_list",
"=",
"a_string",
".",
"split",
"(",
"self",
".",
"RESPONSE_RETURN",
")",
"last_line",
"=",
"response_list",
"[",
"-",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoTpTcCeSSH.send_command | Send command to network device retrieve output until router_prompt or expect_string
By default this method will keep waiting to receive data until the network device prompt is
detected. The current network device prompt will be determined automatically.
command_string = command to execute
... | netmiko/cisco/cisco_tp_tcce.py | def send_command(self, *args, **kwargs):
"""
Send command to network device retrieve output until router_prompt or expect_string
By default this method will keep waiting to receive data until the network device prompt is
detected. The current network device prompt will be determined aut... | def send_command(self, *args, **kwargs):
"""
Send command to network device retrieve output until router_prompt or expect_string
By default this method will keep waiting to receive data until the network device prompt is
detected. The current network device prompt will be determined aut... | [
"Send",
"command",
"to",
"network",
"device",
"retrieve",
"output",
"until",
"router_prompt",
"or",
"expect_string"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_tp_tcce.py#L63-L87 | [
"def",
"send_command",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
">=",
"2",
":",
"expect_string",
"=",
"args",
"[",
"1",
"]",
"else",
":",
"expect_string",
"=",
"kwargs",
".",
"get",
"(",
"\"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | ExtremeNosSSH.save_config | Save Config for Extreme VDX. | netmiko/extreme/extreme_nos_ssh.py | def save_config(
self,
cmd="copy running-config startup-config",
confirm=True,
confirm_response="y",
):
"""Save Config for Extreme VDX."""
return super(ExtremeNosSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | def save_config(
self,
cmd="copy running-config startup-config",
confirm=True,
confirm_response="y",
):
"""Save Config for Extreme VDX."""
return super(ExtremeNosSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"Save",
"Config",
"for",
"Extreme",
"VDX",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_nos_ssh.py#L24-L33 | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"copy running-config startup-config\"",
",",
"confirm",
"=",
"True",
",",
"confirm_response",
"=",
"\"y\"",
",",
")",
":",
"return",
"super",
"(",
"ExtremeNosSSH",
",",
"self",
")",
".",
"save_config",
"(",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | HuaweiBase.exit_config_mode | Exit configuration mode. | netmiko/huawei/huawei.py | def exit_config_mode(self, exit_config="return", pattern=r">"):
"""Exit configuration mode."""
return super(HuaweiBase, self).exit_config_mode(
exit_config=exit_config, pattern=pattern
) | def exit_config_mode(self, exit_config="return", pattern=r">"):
"""Exit configuration mode."""
return super(HuaweiBase, self).exit_config_mode(
exit_config=exit_config, pattern=pattern
) | [
"Exit",
"configuration",
"mode",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/huawei/huawei.py#L24-L28 | [
"def",
"exit_config_mode",
"(",
"self",
",",
"exit_config",
"=",
"\"return\"",
",",
"pattern",
"=",
"r\">\"",
")",
":",
"return",
"super",
"(",
"HuaweiBase",
",",
"self",
")",
".",
"exit_config_mode",
"(",
"exit_config",
"=",
"exit_config",
",",
"pattern",
"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | HuaweiBase.set_base_prompt | Sets self.base_prompt
Used as delimiter for stripping of trailing prompt in output.
Should be set to something that is general and applies in multiple contexts. For Comware
this will be the router prompt with < > or [ ] stripped off.
This will be set on logging in, but not when enteri... | netmiko/huawei/huawei.py | def set_base_prompt(
self, pri_prompt_terminator=">", alt_prompt_terminator="]", delay_factor=1
):
"""
Sets self.base_prompt
Used as delimiter for stripping of trailing prompt in output.
Should be set to something that is general and applies in multiple contexts. For Comwar... | def set_base_prompt(
self, pri_prompt_terminator=">", alt_prompt_terminator="]", delay_factor=1
):
"""
Sets self.base_prompt
Used as delimiter for stripping of trailing prompt in output.
Should be set to something that is general and applies in multiple contexts. For Comwar... | [
"Sets",
"self",
".",
"base_prompt"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/huawei/huawei.py#L46-L85 | [
"def",
"set_base_prompt",
"(",
"self",
",",
"pri_prompt_terminator",
"=",
"\">\"",
",",
"alt_prompt_terminator",
"=",
"\"]\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"log",
".",
"debug",
"(",
"\"In set_base_prompt\"",
")",
"delay_factor",
"=",
"self",
".",
"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | HuaweiBase.save_config | Save Config for HuaweiSSH | netmiko/huawei/huawei.py | def save_config(self, cmd="save", confirm=False, confirm_response=""):
""" Save Config for HuaweiSSH"""
return super(HuaweiBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | def save_config(self, cmd="save", confirm=False, confirm_response=""):
""" Save Config for HuaweiSSH"""
return super(HuaweiBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"Save",
"Config",
"for",
"HuaweiSSH"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/huawei/huawei.py#L87-L91 | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"save\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"HuaweiBase",
",",
"self",
")",
".",
"save_config",
"(",
"cmd",
"=",
"cmd",
",",
"conf... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | HuaweiTelnet.telnet_login | Telnet login for Huawei Devices | netmiko/huawei/huawei.py | def telnet_login(
self,
pri_prompt_terminator=r"]\s*$",
alt_prompt_terminator=r">\s*$",
username_pattern=r"(?:user:|username|login|user name)",
pwd_pattern=r"assword",
delay_factor=1,
max_loops=20,
):
"""Telnet login for Huawei Devices"""
dela... | def telnet_login(
self,
pri_prompt_terminator=r"]\s*$",
alt_prompt_terminator=r">\s*$",
username_pattern=r"(?:user:|username|login|user name)",
pwd_pattern=r"assword",
delay_factor=1,
max_loops=20,
):
"""Telnet login for Huawei Devices"""
dela... | [
"Telnet",
"login",
"for",
"Huawei",
"Devices"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/huawei/huawei.py#L103-L164 | [
"def",
"telnet_login",
"(",
"self",
",",
"pri_prompt_terminator",
"=",
"r\"]\\s*$\"",
",",
"alt_prompt_terminator",
"=",
"r\">\\s*$\"",
",",
"username_pattern",
"=",
"r\"(?:user:|username|login|user name)\"",
",",
"pwd_pattern",
"=",
"r\"assword\"",
",",
"delay_factor",
"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | HuaweiVrpv8SSH.commit | Commit the candidate configuration.
Commit the entered configuration. Raise an error and return the failure
if the commit fails.
default:
command_string = commit
comment:
command_string = commit comment <comment> | netmiko/huawei/huawei.py | def commit(self, comment="", delay_factor=1):
"""
Commit the candidate configuration.
Commit the entered configuration. Raise an error and return the failure
if the commit fails.
default:
command_string = commit
comment:
command_string = commit com... | def commit(self, comment="", delay_factor=1):
"""
Commit the candidate configuration.
Commit the entered configuration. Raise an error and return the failure
if the commit fails.
default:
command_string = commit
comment:
command_string = commit com... | [
"Commit",
"the",
"candidate",
"configuration",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/huawei/huawei.py#L168-L202 | [
"def",
"commit",
"(",
"self",
",",
"comment",
"=",
"\"\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
")",
"error_marker",
"=",
"\"Failed to generate committed config\"",
"command_string",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | asa_scp_handler | Enable/disable SCP on Cisco ASA. | examples/asa_upgrade.py | def asa_scp_handler(ssh_conn, cmd="ssh scopy enable", mode="enable"):
"""Enable/disable SCP on Cisco ASA."""
if mode == "disable":
cmd = "no " + cmd
return ssh_conn.send_config_set([cmd]) | def asa_scp_handler(ssh_conn, cmd="ssh scopy enable", mode="enable"):
"""Enable/disable SCP on Cisco ASA."""
if mode == "disable":
cmd = "no " + cmd
return ssh_conn.send_config_set([cmd]) | [
"Enable",
"/",
"disable",
"SCP",
"on",
"Cisco",
"ASA",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/examples/asa_upgrade.py#L9-L13 | [
"def",
"asa_scp_handler",
"(",
"ssh_conn",
",",
"cmd",
"=",
"\"ssh scopy enable\"",
",",
"mode",
"=",
"\"enable\"",
")",
":",
"if",
"mode",
"==",
"\"disable\"",
":",
"cmd",
"=",
"\"no \"",
"+",
"cmd",
"return",
"ssh_conn",
".",
"send_config_set",
"(",
"[",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | main | Script to upgrade a Cisco ASA. | examples/asa_upgrade.py | def main():
"""Script to upgrade a Cisco ASA."""
try:
ip_addr = raw_input("Enter ASA IP address: ")
except NameError:
ip_addr = input("Enter ASA IP address: ")
my_pass = getpass()
start_time = datetime.now()
print(">>>> {}".format(start_time))
net_device = {
"device_... | def main():
"""Script to upgrade a Cisco ASA."""
try:
ip_addr = raw_input("Enter ASA IP address: ")
except NameError:
ip_addr = input("Enter ASA IP address: ")
my_pass = getpass()
start_time = datetime.now()
print(">>>> {}".format(start_time))
net_device = {
"device_... | [
"Script",
"to",
"upgrade",
"a",
"Cisco",
"ASA",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/examples/asa_upgrade.py#L16-L91 | [
"def",
"main",
"(",
")",
":",
"try",
":",
"ip_addr",
"=",
"raw_input",
"(",
"\"Enter ASA IP address: \"",
")",
"except",
"NameError",
":",
"ip_addr",
"=",
"input",
"(",
"\"Enter ASA IP address: \"",
")",
"my_pass",
"=",
"getpass",
"(",
")",
"start_time",
"=",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | show_version | Execute show version command using Netmiko. | examples/use_cases/case16_concurrency/processes_netmiko.py | def show_version(a_device):
"""Execute show version command using Netmiko."""
remote_conn = ConnectHandler(**a_device)
print()
print("#" * 80)
print(remote_conn.send_command("show version"))
print("#" * 80)
print() | def show_version(a_device):
"""Execute show version command using Netmiko."""
remote_conn = ConnectHandler(**a_device)
print()
print("#" * 80)
print(remote_conn.send_command("show version"))
print("#" * 80)
print() | [
"Execute",
"show",
"version",
"command",
"using",
"Netmiko",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/examples/use_cases/case16_concurrency/processes_netmiko.py#L14-L21 | [
"def",
"show_version",
"(",
"a_device",
")",
":",
"remote_conn",
"=",
"ConnectHandler",
"(",
"*",
"*",
"a_device",
")",
"print",
"(",
")",
"print",
"(",
"\"#\"",
"*",
"80",
")",
"print",
"(",
"remote_conn",
".",
"send_command",
"(",
"\"show version\"",
")"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | main | Use processes and Netmiko to connect to each of the devices. Execute
'show version' on each device. Record the amount of time required to do this. | examples/use_cases/case16_concurrency/processes_netmiko.py | def main():
"""
Use processes and Netmiko to connect to each of the devices. Execute
'show version' on each device. Record the amount of time required to do this.
"""
start_time = datetime.now()
procs = []
for a_device in devices:
my_proc = Process(target=show_version, args=(a_devic... | def main():
"""
Use processes and Netmiko to connect to each of the devices. Execute
'show version' on each device. Record the amount of time required to do this.
"""
start_time = datetime.now()
procs = []
for a_device in devices:
my_proc = Process(target=show_version, args=(a_devic... | [
"Use",
"processes",
"and",
"Netmiko",
"to",
"connect",
"to",
"each",
"of",
"the",
"devices",
".",
"Execute",
"show",
"version",
"on",
"each",
"device",
".",
"Record",
"the",
"amount",
"of",
"time",
"required",
"to",
"do",
"this",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/examples/use_cases/case16_concurrency/processes_netmiko.py#L24-L41 | [
"def",
"main",
"(",
")",
":",
"start_time",
"=",
"datetime",
".",
"now",
"(",
")",
"procs",
"=",
"[",
"]",
"for",
"a_device",
"in",
"devices",
":",
"my_proc",
"=",
"Process",
"(",
"target",
"=",
"show_version",
",",
"args",
"=",
"(",
"a_device",
",",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoWlcSSH.special_login_handler | WLC presents with the following on login (in certain OS versions)
login as: user
(Cisco Controller)
User: user
Password:**** | netmiko/cisco/cisco_wlc_ssh.py | def special_login_handler(self, delay_factor=1):
"""WLC presents with the following on login (in certain OS versions)
login as: user
(Cisco Controller)
User: user
Password:****
"""
delay_factor = self.select_delay_factor(delay_factor)
i = 0
tim... | def special_login_handler(self, delay_factor=1):
"""WLC presents with the following on login (in certain OS versions)
login as: user
(Cisco Controller)
User: user
Password:****
"""
delay_factor = self.select_delay_factor(delay_factor)
i = 0
tim... | [
"WLC",
"presents",
"with",
"the",
"following",
"on",
"login",
"(",
"in",
"certain",
"OS",
"versions",
")"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_wlc_ssh.py#L15-L42 | [
"def",
"special_login_handler",
"(",
"self",
",",
"delay_factor",
"=",
"1",
")",
":",
"delay_factor",
"=",
"self",
".",
"select_delay_factor",
"(",
"delay_factor",
")",
"i",
"=",
"0",
"time",
".",
"sleep",
"(",
"delay_factor",
"*",
"0.5",
")",
"output",
"=... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoWlcSSH.send_command_w_enter | For 'show run-config' Cisco WLC adds a 'Press Enter to continue...' message
Even though pagination is disabled
show run-config also has excessive delays in the output which requires special
handling.
Arguments are the same as send_command_timing() method | netmiko/cisco/cisco_wlc_ssh.py | def send_command_w_enter(self, *args, **kwargs):
"""
For 'show run-config' Cisco WLC adds a 'Press Enter to continue...' message
Even though pagination is disabled
show run-config also has excessive delays in the output which requires special
handling.
Arguments are the s... | def send_command_w_enter(self, *args, **kwargs):
"""
For 'show run-config' Cisco WLC adds a 'Press Enter to continue...' message
Even though pagination is disabled
show run-config also has excessive delays in the output which requires special
handling.
Arguments are the s... | [
"For",
"show",
"run",
"-",
"config",
"Cisco",
"WLC",
"adds",
"a",
"Press",
"Enter",
"to",
"continue",
"...",
"message",
"Even",
"though",
"pagination",
"is",
"disabled",
"show",
"run",
"-",
"config",
"also",
"has",
"excessive",
"delays",
"in",
"the",
"outp... | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_wlc_ssh.py#L44-L94 | [
"def",
"send_command_w_enter",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"1",
":",
"raise",
"ValueError",
"(",
"\"Must pass in delay_factor as keyword argument\"",
")",
"# If no delay_factor use 1 for def... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoWlcSSH.check_config_mode | Checks if the device is in configuration mode or not. | netmiko/cisco/cisco_wlc_ssh.py | def check_config_mode(self, check_string="config", pattern=""):
"""Checks if the device is in configuration mode or not."""
if not pattern:
pattern = re.escape(self.base_prompt)
return super(CiscoWlcSSH, self).check_config_mode(check_string, pattern) | def check_config_mode(self, check_string="config", pattern=""):
"""Checks if the device is in configuration mode or not."""
if not pattern:
pattern = re.escape(self.base_prompt)
return super(CiscoWlcSSH, self).check_config_mode(check_string, pattern) | [
"Checks",
"if",
"the",
"device",
"is",
"in",
"configuration",
"mode",
"or",
"not",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_wlc_ssh.py#L118-L122 | [
"def",
"check_config_mode",
"(",
"self",
",",
"check_string",
"=",
"\"config\"",
",",
"pattern",
"=",
"\"\"",
")",
":",
"if",
"not",
"pattern",
":",
"pattern",
"=",
"re",
".",
"escape",
"(",
"self",
".",
"base_prompt",
")",
"return",
"super",
"(",
"Cisco... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoWlcSSH.exit_config_mode | Exit config_mode. | netmiko/cisco/cisco_wlc_ssh.py | def exit_config_mode(self, exit_config="exit", pattern=""):
"""Exit config_mode."""
if not pattern:
pattern = re.escape(self.base_prompt)
return super(CiscoWlcSSH, self).exit_config_mode(exit_config, pattern) | def exit_config_mode(self, exit_config="exit", pattern=""):
"""Exit config_mode."""
if not pattern:
pattern = re.escape(self.base_prompt)
return super(CiscoWlcSSH, self).exit_config_mode(exit_config, pattern) | [
"Exit",
"config_mode",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_wlc_ssh.py#L130-L134 | [
"def",
"exit_config_mode",
"(",
"self",
",",
"exit_config",
"=",
"\"exit\"",
",",
"pattern",
"=",
"\"\"",
")",
":",
"if",
"not",
"pattern",
":",
"pattern",
"=",
"re",
".",
"escape",
"(",
"self",
".",
"base_prompt",
")",
"return",
"super",
"(",
"CiscoWlcS... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | CiscoWlcSSH.save_config | Saves Config. | netmiko/cisco/cisco_wlc_ssh.py | def save_config(self, cmd="save config", confirm=True, confirm_response="y"):
"""Saves Config."""
self.enable()
if confirm:
output = self.send_command_timing(command_string=cmd)
if confirm_response:
output += self.send_command_timing(confirm_response)
... | def save_config(self, cmd="save config", confirm=True, confirm_response="y"):
"""Saves Config."""
self.enable()
if confirm:
output = self.send_command_timing(command_string=cmd)
if confirm_response:
output += self.send_command_timing(confirm_response)
... | [
"Saves",
"Config",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_wlc_ssh.py#L176-L189 | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"save config\"",
",",
"confirm",
"=",
"True",
",",
"confirm_response",
"=",
"\"y\"",
")",
":",
"self",
".",
"enable",
"(",
")",
"if",
"confirm",
":",
"output",
"=",
"self",
".",
"send_command_timing",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | Row._BuildIndex | Recreate the key index. | netmiko/_textfsm/_texttable.py | def _BuildIndex(self):
"""Recreate the key index."""
self._index = {}
for i, k in enumerate(self._keys):
self._index[k] = i | def _BuildIndex(self):
"""Recreate the key index."""
self._index = {}
for i, k in enumerate(self._keys):
self._index[k] = i | [
"Recreate",
"the",
"key",
"index",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L78-L82 | [
"def",
"_BuildIndex",
"(",
"self",
")",
":",
"self",
".",
"_index",
"=",
"{",
"}",
"for",
"i",
",",
"k",
"in",
"enumerate",
"(",
"self",
".",
"_keys",
")",
":",
"self",
".",
"_index",
"[",
"k",
"]",
"=",
"i"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | Row.get | Get an item from the Row by column name.
Args:
column: Tuple of column names, or a (str) column name, or positional
column number, 0-indexed.
default_value: The value to use if the key is not found.
Returns:
A list or string with column value(s) or default_value if not found. | netmiko/_textfsm/_texttable.py | def get(self, column, default_value=None):
"""Get an item from the Row by column name.
Args:
column: Tuple of column names, or a (str) column name, or positional
column number, 0-indexed.
default_value: The value to use if the key is not found.
Returns:
A list or string with ... | def get(self, column, default_value=None):
"""Get an item from the Row by column name.
Args:
column: Tuple of column names, or a (str) column name, or positional
column number, 0-indexed.
default_value: The value to use if the key is not found.
Returns:
A list or string with ... | [
"Get",
"an",
"item",
"from",
"the",
"Row",
"by",
"column",
"name",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L145-L169 | [
"def",
"get",
"(",
"self",
",",
"column",
",",
"default_value",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"column",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"col",
"in",
"column",
":",
"ret",
".",
"append"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | Row.index | Fetches the column number (0 indexed).
Args:
column: A string, column to fetch the index of.
Returns:
An int, the row index number.
Raises:
ValueError: The specified column was not found. | netmiko/_textfsm/_texttable.py | def index(self, column): # pylint: disable=C6409
"""Fetches the column number (0 indexed).
Args:
column: A string, column to fetch the index of.
Returns:
An int, the row index number.
Raises:
ValueError: The specified column was not found.
"""
for i, key in enumerat... | def index(self, column): # pylint: disable=C6409
"""Fetches the column number (0 indexed).
Args:
column: A string, column to fetch the index of.
Returns:
An int, the row index number.
Raises:
ValueError: The specified column was not found.
"""
for i, key in enumerat... | [
"Fetches",
"the",
"column",
"number",
"(",
"0",
"indexed",
")",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L171-L186 | [
"def",
"index",
"(",
"self",
",",
"column",
")",
":",
"# pylint: disable=C6409",
"for",
"i",
",",
"key",
"in",
"enumerate",
"(",
"self",
".",
"_keys",
")",
":",
"if",
"key",
"==",
"column",
":",
"return",
"i",
"raise",
"ValueError",
"(",
"'Column \"%s\" ... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | Row._SetColour | Sets row's colour attributes to a list of values in terminal.SGR. | netmiko/_textfsm/_texttable.py | def _SetColour(self, value_list):
"""Sets row's colour attributes to a list of values in terminal.SGR."""
if value_list is None:
self._color = None
return
colors = []
for color in value_list:
if color in terminal.SGR:
colors.append(colo... | def _SetColour(self, value_list):
"""Sets row's colour attributes to a list of values in terminal.SGR."""
if value_list is None:
self._color = None
return
colors = []
for color in value_list:
if color in terminal.SGR:
colors.append(colo... | [
"Sets",
"row",
"s",
"colour",
"attributes",
"to",
"a",
"list",
"of",
"values",
"in",
"terminal",
".",
"SGR",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L213-L228 | [
"def",
"_SetColour",
"(",
"self",
",",
"value_list",
")",
":",
"if",
"value_list",
"is",
"None",
":",
"self",
".",
"_color",
"=",
"None",
"return",
"colors",
"=",
"[",
"]",
"for",
"color",
"in",
"value_list",
":",
"if",
"color",
"in",
"terminal",
".",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | Row.Insert | Inserts new values at a specified offset.
Args:
key: string for header value.
value: string for a data value.
row_index: Offset into row for data.
Raises:
IndexError: If the offset is out of bands. | netmiko/_textfsm/_texttable.py | def Insert(self, key, value, row_index):
"""Inserts new values at a specified offset.
Args:
key: string for header value.
value: string for a data value.
row_index: Offset into row for data.
Raises:
IndexError: If the offset is out of bands.
"""
if row_index < 0:
... | def Insert(self, key, value, row_index):
"""Inserts new values at a specified offset.
Args:
key: string for header value.
value: string for a data value.
row_index: Offset into row for data.
Raises:
IndexError: If the offset is out of bands.
"""
if row_index < 0:
... | [
"Inserts",
"new",
"values",
"at",
"a",
"specified",
"offset",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L280-L305 | [
"def",
"Insert",
"(",
"self",
",",
"key",
",",
"value",
",",
"row_index",
")",
":",
"if",
"row_index",
"<",
"0",
":",
"row_index",
"+=",
"len",
"(",
"self",
")",
"if",
"not",
"0",
"<=",
"row_index",
"<",
"len",
"(",
"self",
")",
":",
"raise",
"In... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | TextTable.Map | Applies the function to every row in the table.
Args:
function: A function applied to each row.
Returns:
A new TextTable()
Raises:
TableError: When transform is not invalid row entry. The transform
must be compatible with Append(). | netmiko/_textfsm/_texttable.py | def Map(self, function):
"""Applies the function to every row in the table.
Args:
function: A function applied to each row.
Returns:
A new TextTable()
Raises:
TableError: When transform is not invalid row entry. The transform
must be compatible with Append().
... | def Map(self, function):
"""Applies the function to every row in the table.
Args:
function: A function applied to each row.
Returns:
A new TextTable()
Raises:
TableError: When transform is not invalid row entry. The transform
must be compatible with Append().
... | [
"Applies",
"the",
"function",
"to",
"every",
"row",
"in",
"the",
"table",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L420-L440 | [
"def",
"Map",
"(",
"self",
",",
"function",
")",
":",
"new_table",
"=",
"self",
".",
"__class__",
"(",
")",
"# pylint: disable=protected-access",
"new_table",
".",
"_table",
"=",
"[",
"self",
".",
"header",
"]",
"for",
"row",
"in",
"self",
":",
"filtered_r... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | TextTable.sort | Sorts rows in the texttable.
Args:
cmp: func, non default sort algorithm to use.
key: func, applied to each element before sorting.
reverse: bool, reverse order of sort. | netmiko/_textfsm/_texttable.py | def sort(self, cmp=None, key=None, reverse=False):
"""Sorts rows in the texttable.
Args:
cmp: func, non default sort algorithm to use.
key: func, applied to each element before sorting.
reverse: bool, reverse order of sort.
"""
def _DefaultKey(value):
"""Default k... | def sort(self, cmp=None, key=None, reverse=False):
"""Sorts rows in the texttable.
Args:
cmp: func, non default sort algorithm to use.
key: func, applied to each element before sorting.
reverse: bool, reverse order of sort.
"""
def _DefaultKey(value):
"""Default k... | [
"Sorts",
"rows",
"in",
"the",
"texttable",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L444-L478 | [
"def",
"sort",
"(",
"self",
",",
"cmp",
"=",
"None",
",",
"key",
"=",
"None",
",",
"reverse",
"=",
"False",
")",
":",
"def",
"_DefaultKey",
"(",
"value",
")",
":",
"\"\"\"Default key func is to create a list of all fields.\"\"\"",
"result",
"=",
"[",
"]",
"f... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | TextTable.extend | Extends all rows in the texttable.
The rows are extended with the new columns from the table.
Args:
table: A texttable, the table to extend this table by.
keys: A set, the set of columns to use as the key. If None, the
row index is used.
Raises:
IndexError: If key is not a valid... | netmiko/_textfsm/_texttable.py | def extend(self, table, keys=None):
"""Extends all rows in the texttable.
The rows are extended with the new columns from the table.
Args:
table: A texttable, the table to extend this table by.
keys: A set, the set of columns to use as the key. If None, the
row index is used.
... | def extend(self, table, keys=None):
"""Extends all rows in the texttable.
The rows are extended with the new columns from the table.
Args:
table: A texttable, the table to extend this table by.
keys: A set, the set of columns to use as the key. If None, the
row index is used.
... | [
"Extends",
"all",
"rows",
"in",
"the",
"texttable",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L482-L525 | [
"def",
"extend",
"(",
"self",
",",
"table",
",",
"keys",
"=",
"None",
")",
":",
"if",
"keys",
":",
"for",
"k",
"in",
"keys",
":",
"if",
"k",
"not",
"in",
"self",
".",
"_Header",
"(",
")",
":",
"raise",
"IndexError",
"(",
"\"Unknown key: '%s'\"",
",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | TextTable.Remove | Removes a row from the table.
Args:
row: int, the row number to delete. Must be >= 1, as the header
cannot be removed.
Raises:
TableError: Attempt to remove nonexistent or header row. | netmiko/_textfsm/_texttable.py | def Remove(self, row):
"""Removes a row from the table.
Args:
row: int, the row number to delete. Must be >= 1, as the header
cannot be removed.
Raises:
TableError: Attempt to remove nonexistent or header row.
"""
if row == 0 or row > self.size:
raise TableE... | def Remove(self, row):
"""Removes a row from the table.
Args:
row: int, the row number to delete. Must be >= 1, as the header
cannot be removed.
Raises:
TableError: Attempt to remove nonexistent or header row.
"""
if row == 0 or row > self.size:
raise TableE... | [
"Removes",
"a",
"row",
"from",
"the",
"table",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L528-L547 | [
"def",
"Remove",
"(",
"self",
",",
"row",
")",
":",
"if",
"row",
"==",
"0",
"or",
"row",
">",
"self",
".",
"size",
":",
"raise",
"TableError",
"(",
"\"Attempt to remove header row\"",
")",
"new_table",
"=",
"[",
"]",
"# pylint: disable=E1103",
"for",
"t_ro... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | TextTable._GetRow | Returns the current row as a tuple. | netmiko/_textfsm/_texttable.py | def _GetRow(self, columns=None):
"""Returns the current row as a tuple."""
row = self._table[self._row_index]
if columns:
result = []
for col in columns:
if col not in self.header:
raise TableError("Column header %s not known in table.... | def _GetRow(self, columns=None):
"""Returns the current row as a tuple."""
row = self._table[self._row_index]
if columns:
result = []
for col in columns:
if col not in self.header:
raise TableError("Column header %s not known in table.... | [
"Returns",
"the",
"current",
"row",
"as",
"a",
"tuple",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L553-L564 | [
"def",
"_GetRow",
"(",
"self",
",",
"columns",
"=",
"None",
")",
":",
"row",
"=",
"self",
".",
"_table",
"[",
"self",
".",
"_row_index",
"]",
"if",
"columns",
":",
"result",
"=",
"[",
"]",
"for",
"col",
"in",
"columns",
":",
"if",
"col",
"not",
"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | TextTable._SetRow | Sets the current row to new list.
Args:
new_values: List|dict of new values to insert into row.
row: int, Row to insert values into.
Raises:
TableError: If number of new values is not equal to row size. | netmiko/_textfsm/_texttable.py | def _SetRow(self, new_values, row=0):
"""Sets the current row to new list.
Args:
new_values: List|dict of new values to insert into row.
row: int, Row to insert values into.
Raises:
TableError: If number of new values is not equal to row size.
"""
if not row:
... | def _SetRow(self, new_values, row=0):
"""Sets the current row to new list.
Args:
new_values: List|dict of new values to insert into row.
row: int, Row to insert values into.
Raises:
TableError: If number of new values is not equal to row size.
"""
if not row:
... | [
"Sets",
"the",
"current",
"row",
"to",
"new",
"list",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L566-L583 | [
"def",
"_SetRow",
"(",
"self",
",",
"new_values",
",",
"row",
"=",
"0",
")",
":",
"if",
"not",
"row",
":",
"row",
"=",
"self",
".",
"_row_index",
"if",
"row",
">",
"self",
".",
"size",
":",
"raise",
"TableError",
"(",
"\"Entry %s beyond table size %s.\""... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | TextTable._SetHeader | Sets header of table to the given tuple.
Args:
new_values: Tuple of new header values. | netmiko/_textfsm/_texttable.py | def _SetHeader(self, new_values):
"""Sets header of table to the given tuple.
Args:
new_values: Tuple of new header values.
"""
row = self.row_class()
row.row = 0
for v in new_values:
row[v] = v
self._table[0] = row | def _SetHeader(self, new_values):
"""Sets header of table to the given tuple.
Args:
new_values: Tuple of new header values.
"""
row = self.row_class()
row.row = 0
for v in new_values:
row[v] = v
self._table[0] = row | [
"Sets",
"header",
"of",
"table",
"to",
"the",
"given",
"tuple",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L585-L595 | [
"def",
"_SetHeader",
"(",
"self",
",",
"new_values",
")",
":",
"row",
"=",
"self",
".",
"row_class",
"(",
")",
"row",
".",
"row",
"=",
"0",
"for",
"v",
"in",
"new_values",
":",
"row",
"[",
"v",
"]",
"=",
"v",
"self",
".",
"_table",
"[",
"0",
"]... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | TextTable._SmallestColSize | Finds the largest indivisible word of a string.
...and thus the smallest possible column width that can contain that
word unsplit over rows.
Args:
text: A string of text potentially consisting of words.
Returns:
Integer size of the largest single word in the text. | netmiko/_textfsm/_texttable.py | def _SmallestColSize(self, text):
"""Finds the largest indivisible word of a string.
...and thus the smallest possible column width that can contain that
word unsplit over rows.
Args:
text: A string of text potentially consisting of words.
Returns:
Integer size of the largest sing... | def _SmallestColSize(self, text):
"""Finds the largest indivisible word of a string.
...and thus the smallest possible column width that can contain that
word unsplit over rows.
Args:
text: A string of text potentially consisting of words.
Returns:
Integer size of the largest sing... | [
"Finds",
"the",
"largest",
"indivisible",
"word",
"of",
"a",
"string",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L637-L652 | [
"def",
"_SmallestColSize",
"(",
"self",
",",
"text",
")",
":",
"if",
"not",
"text",
":",
"return",
"0",
"stripped",
"=",
"terminal",
".",
"StripAnsiText",
"(",
"text",
")",
"return",
"max",
"(",
"len",
"(",
"word",
")",
"for",
"word",
"in",
"stripped",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | TextTable.RowWith | Retrieves the first non header row with the column of the given value.
Args:
column: str, the name of the column to check.
value: str, The value of the column to check.
Returns:
A Row() of the first row found, None otherwise.
Raises:
IndexError: The specified column does not exist... | netmiko/_textfsm/_texttable.py | def RowWith(self, column, value):
"""Retrieves the first non header row with the column of the given value.
Args:
column: str, the name of the column to check.
value: str, The value of the column to check.
Returns:
A Row() of the first row found, None otherwise.
Raises:
In... | def RowWith(self, column, value):
"""Retrieves the first non header row with the column of the given value.
Args:
column: str, the name of the column to check.
value: str, The value of the column to check.
Returns:
A Row() of the first row found, None otherwise.
Raises:
In... | [
"Retrieves",
"the",
"first",
"non",
"header",
"row",
"with",
"the",
"column",
"of",
"the",
"given",
"value",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L965-L981 | [
"def",
"RowWith",
"(",
"self",
",",
"column",
",",
"value",
")",
":",
"for",
"row",
"in",
"self",
".",
"_table",
"[",
"1",
":",
"]",
":",
"if",
"row",
"[",
"column",
"]",
"==",
"value",
":",
"return",
"row",
"return",
"None"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | TextTable.AddColumn | Appends a new column to the table.
Args:
column: A string, name of the column to add.
default: Default value for entries. Defaults to ''.
col_index: Integer index for where to insert new column.
Raises:
TableError: Column name already exists. | netmiko/_textfsm/_texttable.py | def AddColumn(self, column, default="", col_index=-1):
"""Appends a new column to the table.
Args:
column: A string, name of the column to add.
default: Default value for entries. Defaults to ''.
col_index: Integer index for where to insert new column.
Raises:
TableError: Colum... | def AddColumn(self, column, default="", col_index=-1):
"""Appends a new column to the table.
Args:
column: A string, name of the column to add.
default: Default value for entries. Defaults to ''.
col_index: Integer index for where to insert new column.
Raises:
TableError: Colum... | [
"Appends",
"a",
"new",
"column",
"to",
"the",
"table",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L983-L1004 | [
"def",
"AddColumn",
"(",
"self",
",",
"column",
",",
"default",
"=",
"\"\"",
",",
"col_index",
"=",
"-",
"1",
")",
":",
"if",
"column",
"in",
"self",
".",
"table",
":",
"raise",
"TableError",
"(",
"\"Column %r already in table.\"",
"%",
"column",
")",
"i... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | TextTable.Append | Adds a new row (list) to the table.
Args:
new_values: Tuple, dict, or Row() of new values to append as a row.
Raises:
TableError: Supplied tuple not equal to table width. | netmiko/_textfsm/_texttable.py | def Append(self, new_values):
"""Adds a new row (list) to the table.
Args:
new_values: Tuple, dict, or Row() of new values to append as a row.
Raises:
TableError: Supplied tuple not equal to table width.
"""
newrow = self.NewRow()
newrow.values = new_values
self... | def Append(self, new_values):
"""Adds a new row (list) to the table.
Args:
new_values: Tuple, dict, or Row() of new values to append as a row.
Raises:
TableError: Supplied tuple not equal to table width.
"""
newrow = self.NewRow()
newrow.values = new_values
self... | [
"Adds",
"a",
"new",
"row",
"(",
"list",
")",
"to",
"the",
"table",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L1006-L1017 | [
"def",
"Append",
"(",
"self",
",",
"new_values",
")",
":",
"newrow",
"=",
"self",
".",
"NewRow",
"(",
")",
"newrow",
".",
"values",
"=",
"new_values",
"self",
".",
"_table",
".",
"append",
"(",
"newrow",
")"
] | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | TextTable.NewRow | Fetches a new, empty row, with headers populated.
Args:
value: Initial value to set each row entry to.
Returns:
A Row() object. | netmiko/_textfsm/_texttable.py | def NewRow(self, value=""):
"""Fetches a new, empty row, with headers populated.
Args:
value: Initial value to set each row entry to.
Returns:
A Row() object.
"""
newrow = self.row_class()
newrow.row = self.size + 1
newrow.table = self
headers = self._He... | def NewRow(self, value=""):
"""Fetches a new, empty row, with headers populated.
Args:
value: Initial value to set each row entry to.
Returns:
A Row() object.
"""
newrow = self.row_class()
newrow.row = self.size + 1
newrow.table = self
headers = self._He... | [
"Fetches",
"a",
"new",
"empty",
"row",
"with",
"headers",
"populated",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L1019-L1034 | [
"def",
"NewRow",
"(",
"self",
",",
"value",
"=",
"\"\"",
")",
":",
"newrow",
"=",
"self",
".",
"row_class",
"(",
")",
"newrow",
".",
"row",
"=",
"self",
".",
"size",
"+",
"1",
"newrow",
".",
"table",
"=",
"self",
"headers",
"=",
"self",
".",
"_He... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | TextTable.CsvToTable | Parses buffer into tabular format.
Strips off comments (preceded by '#').
Optionally parses and indexes by first line (header).
Args:
buf: String file buffer containing CSV data.
header: Is the first line of buffer a header.
separator: String that CSV is separated by.
Returns:
... | netmiko/_textfsm/_texttable.py | def CsvToTable(self, buf, header=True, separator=","):
"""Parses buffer into tabular format.
Strips off comments (preceded by '#').
Optionally parses and indexes by first line (header).
Args:
buf: String file buffer containing CSV data.
header: Is the first line of buffer a header.
... | def CsvToTable(self, buf, header=True, separator=","):
"""Parses buffer into tabular format.
Strips off comments (preceded by '#').
Optionally parses and indexes by first line (header).
Args:
buf: String file buffer containing CSV data.
header: Is the first line of buffer a header.
... | [
"Parses",
"buffer",
"into",
"tabular",
"format",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/_textfsm/_texttable.py#L1036-L1103 | [
"def",
"CsvToTable",
"(",
"self",
",",
"buf",
",",
"header",
"=",
"True",
",",
"separator",
"=",
"\",\"",
")",
":",
"self",
".",
"Reset",
"(",
")",
"header_row",
"=",
"self",
".",
"row_class",
"(",
")",
"if",
"header",
":",
"line",
"=",
"buf",
".",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | ExtremeVspSSH.save_config | Save Config | netmiko/extreme/extreme_vsp_ssh.py | def save_config(self, cmd="save config", confirm=False, confirm_response=""):
"""Save Config"""
return super(ExtremeVspSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | def save_config(self, cmd="save config", confirm=False, confirm_response=""):
"""Save Config"""
return super(ExtremeVspSSH, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"Save",
"Config"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_vsp_ssh.py#L20-L24 | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"save config\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"ExtremeVspSSH",
",",
"self",
")",
".",
"save_config",
"(",
"cmd",
"=",
"cmd",
",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | PluribusSSH.disable_paging | Make sure paging is disabled. | netmiko/pluribus/pluribus_ssh.py | def disable_paging(self, command="pager off", delay_factor=1):
"""Make sure paging is disabled."""
return super(PluribusSSH, self).disable_paging(
command=command, delay_factor=delay_factor
) | def disable_paging(self, command="pager off", delay_factor=1):
"""Make sure paging is disabled."""
return super(PluribusSSH, self).disable_paging(
command=command, delay_factor=delay_factor
) | [
"Make",
"sure",
"paging",
"is",
"disabled",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/pluribus/pluribus_ssh.py#L13-L17 | [
"def",
"disable_paging",
"(",
"self",
",",
"command",
"=",
"\"pager off\"",
",",
"delay_factor",
"=",
"1",
")",
":",
"return",
"super",
"(",
"PluribusSSH",
",",
"self",
")",
".",
"disable_paging",
"(",
"command",
"=",
"command",
",",
"delay_factor",
"=",
"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | load_yaml_file | Read YAML file. | netmiko/utilities.py | def load_yaml_file(yaml_file):
"""Read YAML file."""
try:
import yaml
except ImportError:
sys.exit("Unable to import yaml module.")
try:
with io.open(yaml_file, "rt", encoding="utf-8") as fname:
return yaml.safe_load(fname)
except IOError:
sys.exit("Unable... | def load_yaml_file(yaml_file):
"""Read YAML file."""
try:
import yaml
except ImportError:
sys.exit("Unable to import yaml module.")
try:
with io.open(yaml_file, "rt", encoding="utf-8") as fname:
return yaml.safe_load(fname)
except IOError:
sys.exit("Unable... | [
"Read",
"YAML",
"file",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L55-L65 | [
"def",
"load_yaml_file",
"(",
"yaml_file",
")",
":",
"try",
":",
"import",
"yaml",
"except",
"ImportError",
":",
"sys",
".",
"exit",
"(",
"\"Unable to import yaml module.\"",
")",
"try",
":",
"with",
"io",
".",
"open",
"(",
"yaml_file",
",",
"\"rt\"",
",",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | find_cfg_file | Look for .netmiko.yml in current dir, then ~/.netmiko.yml. | netmiko/utilities.py | def find_cfg_file(file_name=None):
"""Look for .netmiko.yml in current dir, then ~/.netmiko.yml."""
base_file = ".netmiko.yml"
check_files = [base_file, os.path.expanduser("~") + "/" + base_file]
if file_name:
check_files.insert(0, file_name)
for test_file in check_files:
if os.path.... | def find_cfg_file(file_name=None):
"""Look for .netmiko.yml in current dir, then ~/.netmiko.yml."""
base_file = ".netmiko.yml"
check_files = [base_file, os.path.expanduser("~") + "/" + base_file]
if file_name:
check_files.insert(0, file_name)
for test_file in check_files:
if os.path.... | [
"Look",
"for",
".",
"netmiko",
".",
"yml",
"in",
"current",
"dir",
"then",
"~",
"/",
".",
"netmiko",
".",
"yml",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L74-L83 | [
"def",
"find_cfg_file",
"(",
"file_name",
"=",
"None",
")",
":",
"base_file",
"=",
"\".netmiko.yml\"",
"check_files",
"=",
"[",
"base_file",
",",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~\"",
")",
"+",
"\"/\"",
"+",
"base_file",
"]",
"if",
"file_name... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | display_inventory | Print out inventory devices and groups. | netmiko/utilities.py | def display_inventory(my_devices):
"""Print out inventory devices and groups."""
inventory_groups = ["all"]
inventory_devices = []
for k, v in my_devices.items():
if isinstance(v, list):
inventory_groups.append(k)
elif isinstance(v, dict):
inventory_devices.append... | def display_inventory(my_devices):
"""Print out inventory devices and groups."""
inventory_groups = ["all"]
inventory_devices = []
for k, v in my_devices.items():
if isinstance(v, list):
inventory_groups.append(k)
elif isinstance(v, dict):
inventory_devices.append... | [
"Print",
"out",
"inventory",
"devices",
"and",
"groups",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L86-L107 | [
"def",
"display_inventory",
"(",
"my_devices",
")",
":",
"inventory_groups",
"=",
"[",
"\"all\"",
"]",
"inventory_devices",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"my_devices",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"list",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | obtain_all_devices | Dynamically create 'all' group. | netmiko/utilities.py | def obtain_all_devices(my_devices):
"""Dynamically create 'all' group."""
new_devices = {}
for device_name, device_or_group in my_devices.items():
# Skip any groups
if not isinstance(device_or_group, list):
new_devices[device_name] = device_or_group
return new_devices | def obtain_all_devices(my_devices):
"""Dynamically create 'all' group."""
new_devices = {}
for device_name, device_or_group in my_devices.items():
# Skip any groups
if not isinstance(device_or_group, list):
new_devices[device_name] = device_or_group
return new_devices | [
"Dynamically",
"create",
"all",
"group",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L110-L117 | [
"def",
"obtain_all_devices",
"(",
"my_devices",
")",
":",
"new_devices",
"=",
"{",
"}",
"for",
"device_name",
",",
"device_or_group",
"in",
"my_devices",
".",
"items",
"(",
")",
":",
"# Skip any groups",
"if",
"not",
"isinstance",
"(",
"device_or_group",
",",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | ensure_dir_exists | Ensure directory exists. Create if necessary. | netmiko/utilities.py | def ensure_dir_exists(verify_dir):
"""Ensure directory exists. Create if necessary."""
if not os.path.exists(verify_dir):
# Doesn't exist create dir
os.makedirs(verify_dir)
else:
# Exists
if not os.path.isdir(verify_dir):
# Not a dir, raise an exception
... | def ensure_dir_exists(verify_dir):
"""Ensure directory exists. Create if necessary."""
if not os.path.exists(verify_dir):
# Doesn't exist create dir
os.makedirs(verify_dir)
else:
# Exists
if not os.path.isdir(verify_dir):
# Not a dir, raise an exception
... | [
"Ensure",
"directory",
"exists",
".",
"Create",
"if",
"necessary",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L133-L142 | [
"def",
"ensure_dir_exists",
"(",
"verify_dir",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"verify_dir",
")",
":",
"# Doesn't exist create dir",
"os",
".",
"makedirs",
"(",
"verify_dir",
")",
"else",
":",
"# Exists",
"if",
"not",
"os",
".... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | find_netmiko_dir | Check environment first, then default dir | netmiko/utilities.py | def find_netmiko_dir():
"""Check environment first, then default dir"""
try:
netmiko_base_dir = os.environ["NETMIKO_DIR"]
except KeyError:
netmiko_base_dir = NETMIKO_BASE_DIR
netmiko_base_dir = os.path.expanduser(netmiko_base_dir)
if netmiko_base_dir == "/":
raise ValueError(... | def find_netmiko_dir():
"""Check environment first, then default dir"""
try:
netmiko_base_dir = os.environ["NETMIKO_DIR"]
except KeyError:
netmiko_base_dir = NETMIKO_BASE_DIR
netmiko_base_dir = os.path.expanduser(netmiko_base_dir)
if netmiko_base_dir == "/":
raise ValueError(... | [
"Check",
"environment",
"first",
"then",
"default",
"dir"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L145-L155 | [
"def",
"find_netmiko_dir",
"(",
")",
":",
"try",
":",
"netmiko_base_dir",
"=",
"os",
".",
"environ",
"[",
"\"NETMIKO_DIR\"",
"]",
"except",
"KeyError",
":",
"netmiko_base_dir",
"=",
"NETMIKO_BASE_DIR",
"netmiko_base_dir",
"=",
"os",
".",
"path",
".",
"expanduser... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | write_bytes | Write Python2 and Python3 compatible byte stream. | netmiko/utilities.py | def write_bytes(out_data, encoding="ascii"):
"""Write Python2 and Python3 compatible byte stream."""
if sys.version_info[0] >= 3:
if isinstance(out_data, type("")):
if encoding == "utf-8":
return out_data.encode("utf-8")
else:
return out_data.encod... | def write_bytes(out_data, encoding="ascii"):
"""Write Python2 and Python3 compatible byte stream."""
if sys.version_info[0] >= 3:
if isinstance(out_data, type("")):
if encoding == "utf-8":
return out_data.encode("utf-8")
else:
return out_data.encod... | [
"Write",
"Python2",
"and",
"Python3",
"compatible",
"byte",
"stream",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L158-L179 | [
"def",
"write_bytes",
"(",
"out_data",
",",
"encoding",
"=",
"\"ascii\"",
")",
":",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
">=",
"3",
":",
"if",
"isinstance",
"(",
"out_data",
",",
"type",
"(",
"\"\"",
")",
")",
":",
"if",
"encoding",
"==",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | check_serial_port | returns valid COM Port. | netmiko/utilities.py | def check_serial_port(name):
"""returns valid COM Port."""
try:
cdc = next(serial.tools.list_ports.grep(name))
return cdc[0]
except StopIteration:
msg = "device {} not found. ".format(name)
msg += "available devices are: "
ports = list(serial.tools.list_ports.comports... | def check_serial_port(name):
"""returns valid COM Port."""
try:
cdc = next(serial.tools.list_ports.grep(name))
return cdc[0]
except StopIteration:
msg = "device {} not found. ".format(name)
msg += "available devices are: "
ports = list(serial.tools.list_ports.comports... | [
"returns",
"valid",
"COM",
"Port",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L182-L193 | [
"def",
"check_serial_port",
"(",
"name",
")",
":",
"try",
":",
"cdc",
"=",
"next",
"(",
"serial",
".",
"tools",
".",
"list_ports",
".",
"grep",
"(",
"name",
")",
")",
"return",
"cdc",
"[",
"0",
"]",
"except",
"StopIteration",
":",
"msg",
"=",
"\"devi... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | get_template_dir | Find and return the ntc-templates/templates dir. | netmiko/utilities.py | def get_template_dir():
"""Find and return the ntc-templates/templates dir."""
try:
template_dir = os.path.expanduser(os.environ["NET_TEXTFSM"])
index = os.path.join(template_dir, "index")
if not os.path.isfile(index):
# Assume only base ./ntc-templates specified
... | def get_template_dir():
"""Find and return the ntc-templates/templates dir."""
try:
template_dir = os.path.expanduser(os.environ["NET_TEXTFSM"])
index = os.path.join(template_dir, "index")
if not os.path.isfile(index):
# Assume only base ./ntc-templates specified
... | [
"Find",
"and",
"return",
"the",
"ntc",
"-",
"templates",
"/",
"templates",
"dir",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L196-L216 | [
"def",
"get_template_dir",
"(",
")",
":",
"try",
":",
"template_dir",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"os",
".",
"environ",
"[",
"\"NET_TEXTFSM\"",
"]",
")",
"index",
"=",
"os",
".",
"path",
".",
"join",
"(",
"template_dir",
",",
"\"ind... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | clitable_to_dict | Converts TextFSM cli_table object to list of dictionaries. | netmiko/utilities.py | def clitable_to_dict(cli_table):
"""Converts TextFSM cli_table object to list of dictionaries."""
objs = []
for row in cli_table:
temp_dict = {}
for index, element in enumerate(row):
temp_dict[cli_table.header[index].lower()] = element
objs.append(temp_dict)
return ob... | def clitable_to_dict(cli_table):
"""Converts TextFSM cli_table object to list of dictionaries."""
objs = []
for row in cli_table:
temp_dict = {}
for index, element in enumerate(row):
temp_dict[cli_table.header[index].lower()] = element
objs.append(temp_dict)
return ob... | [
"Converts",
"TextFSM",
"cli_table",
"object",
"to",
"list",
"of",
"dictionaries",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L219-L227 | [
"def",
"clitable_to_dict",
"(",
"cli_table",
")",
":",
"objs",
"=",
"[",
"]",
"for",
"row",
"in",
"cli_table",
":",
"temp_dict",
"=",
"{",
"}",
"for",
"index",
",",
"element",
"in",
"enumerate",
"(",
"row",
")",
":",
"temp_dict",
"[",
"cli_table",
".",... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | get_structured_data | Convert raw CLI output to structured data using TextFSM template. | netmiko/utilities.py | def get_structured_data(raw_output, platform, command):
"""Convert raw CLI output to structured data using TextFSM template."""
template_dir = get_template_dir()
index_file = os.path.join(template_dir, "index")
textfsm_obj = clitable.CliTable(index_file, template_dir)
attrs = {"Command": command, "P... | def get_structured_data(raw_output, platform, command):
"""Convert raw CLI output to structured data using TextFSM template."""
template_dir = get_template_dir()
index_file = os.path.join(template_dir, "index")
textfsm_obj = clitable.CliTable(index_file, template_dir)
attrs = {"Command": command, "P... | [
"Convert",
"raw",
"CLI",
"output",
"to",
"structured",
"data",
"using",
"TextFSM",
"template",
"."
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/utilities.py#L230-L243 | [
"def",
"get_structured_data",
"(",
"raw_output",
",",
"platform",
",",
"command",
")",
":",
"template_dir",
"=",
"get_template_dir",
"(",
")",
"index_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"template_dir",
",",
"\"index\"",
")",
"textfsm_obj",
"=",
... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | ExtremeNetironBase.save_config | Save Config | netmiko/extreme/extreme_netiron.py | def save_config(self, cmd="write memory", confirm=False, confirm_response=""):
"""Save Config"""
return super(ExtremeNetironBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | def save_config(self, cmd="write memory", confirm=False, confirm_response=""):
"""Save Config"""
return super(ExtremeNetironBase, self).save_config(
cmd=cmd, confirm=confirm, confirm_response=confirm_response
) | [
"Save",
"Config"
] | ktbyers/netmiko | python | https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/extreme/extreme_netiron.py#L6-L10 | [
"def",
"save_config",
"(",
"self",
",",
"cmd",
"=",
"\"write memory\"",
",",
"confirm",
"=",
"False",
",",
"confirm_response",
"=",
"\"\"",
")",
":",
"return",
"super",
"(",
"ExtremeNetironBase",
",",
"self",
")",
".",
"save_config",
"(",
"cmd",
"=",
"cmd"... | 54e6116c0b4664de2123081937e0a9a27bdfdfea |
train | main | Create a ElastiCache Redis Node and EC2 Instance | examples/ElastiCacheRedis.py | def main():
"""
Create a ElastiCache Redis Node and EC2 Instance
"""
template = Template()
# Description
template.add_description(
'AWS CloudFormation Sample Template ElastiCache_Redis:'
'Sample template showing how to create an Amazon'
'ElastiCache Redis Cluster. **WAR... | def main():
"""
Create a ElastiCache Redis Node and EC2 Instance
"""
template = Template()
# Description
template.add_description(
'AWS CloudFormation Sample Template ElastiCache_Redis:'
'Sample template showing how to create an Amazon'
'ElastiCache Redis Cluster. **WAR... | [
"Create",
"a",
"ElastiCache",
"Redis",
"Node",
"and",
"EC2",
"Instance"
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/examples/ElastiCacheRedis.py#L36-L523 | [
"def",
"main",
"(",
")",
":",
"template",
"=",
"Template",
"(",
")",
"# Description",
"template",
".",
"add_description",
"(",
"'AWS CloudFormation Sample Template ElastiCache_Redis:'",
"'Sample template showing how to create an Amazon'",
"'ElastiCache Redis Cluster. **WARNING** Th... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | validate_iops | DBInstance Iops validation rules. | troposphere/rds.py | def validate_iops(iops):
"""DBInstance Iops validation rules."""
iops = integer(iops)
if int(iops) == 0:
return iops
if int(iops) < 1000:
raise ValueError("DBInstance Iops, if set, must be greater than 1000.")
return iops | def validate_iops(iops):
"""DBInstance Iops validation rules."""
iops = integer(iops)
if int(iops) == 0:
return iops
if int(iops) < 1000:
raise ValueError("DBInstance Iops, if set, must be greater than 1000.")
return iops | [
"DBInstance",
"Iops",
"validation",
"rules",
"."
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/rds.py#L26-L34 | [
"def",
"validate_iops",
"(",
"iops",
")",
":",
"iops",
"=",
"integer",
"(",
"iops",
")",
"if",
"int",
"(",
"iops",
")",
"==",
"0",
":",
"return",
"iops",
"if",
"int",
"(",
"iops",
")",
"<",
"1000",
":",
"raise",
"ValueError",
"(",
"\"DBInstance Iops,... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | validate_backup_window | Validate PreferredBackupWindow for DBInstance | troposphere/rds.py | def validate_backup_window(window):
"""Validate PreferredBackupWindow for DBInstance"""
hour = r'[01]?[0-9]|2[0-3]'
minute = r'[0-5][0-9]'
r = ("(?P<start_hour>%s):(?P<start_minute>%s)-"
"(?P<end_hour>%s):(?P<end_minute>%s)") % (hour, minute, hour, minute)
range_regex = re.compile(r)
m... | def validate_backup_window(window):
"""Validate PreferredBackupWindow for DBInstance"""
hour = r'[01]?[0-9]|2[0-3]'
minute = r'[0-5][0-9]'
r = ("(?P<start_hour>%s):(?P<start_minute>%s)-"
"(?P<end_hour>%s):(?P<end_minute>%s)") % (hour, minute, hour, minute)
range_regex = re.compile(r)
m... | [
"Validate",
"PreferredBackupWindow",
"for",
"DBInstance"
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/rds.py#L73-L90 | [
"def",
"validate_backup_window",
"(",
"window",
")",
":",
"hour",
"=",
"r'[01]?[0-9]|2[0-3]'",
"minute",
"=",
"r'[0-5][0-9]'",
"r",
"=",
"(",
"\"(?P<start_hour>%s):(?P<start_minute>%s)-\"",
"\"(?P<end_hour>%s):(?P<end_minute>%s)\"",
")",
"%",
"(",
"hour",
",",
"minute",
... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | validate_maintenance_window | Validate PreferredMaintenanceWindow for DBInstance | troposphere/rds.py | def validate_maintenance_window(window):
"""Validate PreferredMaintenanceWindow for DBInstance"""
days = ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
day_re = r'[A-Z]{1}[a-z]{2}'
hour = r'[01]?[0-9]|2[0-3]'
minute = r'[0-5][0-9]'
r = ("(?P<start_day>%s):(?P<start_hour>%s):(?P<start_minute>... | def validate_maintenance_window(window):
"""Validate PreferredMaintenanceWindow for DBInstance"""
days = ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
day_re = r'[A-Z]{1}[a-z]{2}'
hour = r'[01]?[0-9]|2[0-3]'
minute = r'[0-5][0-9]'
r = ("(?P<start_day>%s):(?P<start_hour>%s):(?P<start_minute>... | [
"Validate",
"PreferredMaintenanceWindow",
"for",
"DBInstance"
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/rds.py#L93-L122 | [
"def",
"validate_maintenance_window",
"(",
"window",
")",
":",
"days",
"=",
"(",
"\"Mon\"",
",",
"\"Tue\"",
",",
"\"Wed\"",
",",
"\"Thu\"",
",",
"\"Fri\"",
",",
"\"Sat\"",
",",
"\"Sun\"",
")",
"day_re",
"=",
"r'[A-Z]{1}[a-z]{2}'",
"hour",
"=",
"r'[01]?[0-9]|2[... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | validate_capacity | Validate ScalingConfiguration capacity for serverless DBCluster | troposphere/rds.py | def validate_capacity(capacity):
"""Validate ScalingConfiguration capacity for serverless DBCluster"""
if capacity not in VALID_SCALING_CONFIGURATION_CAPACITIES:
raise ValueError(
"ScalingConfiguration capacity must be one of: {}".format(
", ".join(map(
s... | def validate_capacity(capacity):
"""Validate ScalingConfiguration capacity for serverless DBCluster"""
if capacity not in VALID_SCALING_CONFIGURATION_CAPACITIES:
raise ValueError(
"ScalingConfiguration capacity must be one of: {}".format(
", ".join(map(
s... | [
"Validate",
"ScalingConfiguration",
"capacity",
"for",
"serverless",
"DBCluster"
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/rds.py#L135-L147 | [
"def",
"validate_capacity",
"(",
"capacity",
")",
":",
"if",
"capacity",
"not",
"in",
"VALID_SCALING_CONFIGURATION_CAPACITIES",
":",
"raise",
"ValueError",
"(",
"\"ScalingConfiguration capacity must be one of: {}\"",
".",
"format",
"(",
"\", \"",
".",
"join",
"(",
"map"... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | file_contents | Given a file name to a valid file returns the file object. | setup.py | def file_contents(file_name):
"""Given a file name to a valid file returns the file object."""
curr_dir = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(curr_dir, file_name)) as the_file:
contents = the_file.read()
return contents | def file_contents(file_name):
"""Given a file name to a valid file returns the file object."""
curr_dir = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(curr_dir, file_name)) as the_file:
contents = the_file.read()
return contents | [
"Given",
"a",
"file",
"name",
"to",
"a",
"valid",
"file",
"returns",
"the",
"file",
"object",
"."
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/setup.py#L26-L31 | [
"def",
"file_contents",
"(",
"file_name",
")",
":",
"curr_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"curr_dir",
",",
"f... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | depends_on_helper | Handles using .title if the given object is a troposphere resource.
If the given object is a troposphere resource, use the `.title` attribute
of that resource. If it's a string, just use the string. This should allow
more pythonic use of DependsOn. | troposphere/__init__.py | def depends_on_helper(obj):
""" Handles using .title if the given object is a troposphere resource.
If the given object is a troposphere resource, use the `.title` attribute
of that resource. If it's a string, just use the string. This should allow
more pythonic use of DependsOn.
"""
if isinsta... | def depends_on_helper(obj):
""" Handles using .title if the given object is a troposphere resource.
If the given object is a troposphere resource, use the `.title` attribute
of that resource. If it's a string, just use the string. This should allow
more pythonic use of DependsOn.
"""
if isinsta... | [
"Handles",
"using",
".",
"title",
"if",
"the",
"given",
"object",
"is",
"a",
"troposphere",
"resource",
"."
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/__init__.py#L76-L87 | [
"def",
"depends_on_helper",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"AWSObject",
")",
":",
"return",
"obj",
".",
"title",
"elif",
"isinstance",
"(",
"obj",
",",
"list",
")",
":",
"return",
"list",
"(",
"map",
"(",
"depends_on_helper",
... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | Template.set_parameter_label | Sets the Label used in the User Interface for the given parameter.
:type parameter: str or Parameter
:type label: str | troposphere/__init__.py | def set_parameter_label(self, parameter, label):
"""
Sets the Label used in the User Interface for the given parameter.
:type parameter: str or Parameter
:type label: str
"""
labels = self.metadata\
.setdefault("AWS::CloudFormation::Interface", {})\
... | def set_parameter_label(self, parameter, label):
"""
Sets the Label used in the User Interface for the given parameter.
:type parameter: str or Parameter
:type label: str
"""
labels = self.metadata\
.setdefault("AWS::CloudFormation::Interface", {})\
... | [
"Sets",
"the",
"Label",
"used",
"in",
"the",
"User",
"Interface",
"for",
"the",
"given",
"parameter",
".",
":",
"type",
"parameter",
":",
"str",
"or",
"Parameter",
":",
"type",
"label",
":",
"str"
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/__init__.py#L710-L723 | [
"def",
"set_parameter_label",
"(",
"self",
",",
"parameter",
",",
"label",
")",
":",
"labels",
"=",
"self",
".",
"metadata",
".",
"setdefault",
"(",
"\"AWS::CloudFormation::Interface\"",
",",
"{",
"}",
")",
".",
"setdefault",
"(",
"\"ParameterLabels\"",
",",
"... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | Template.add_parameter_to_group | Add a parameter under a group (created if needed).
:type parameter: str or Parameter
:type group_name: str | troposphere/__init__.py | def add_parameter_to_group(self, parameter, group_name):
"""
Add a parameter under a group (created if needed).
:type parameter: str or Parameter
:type group_name: str
"""
groups = self.metadata \
.setdefault("AWS::CloudFormation::Interface", {}) \
... | def add_parameter_to_group(self, parameter, group_name):
"""
Add a parameter under a group (created if needed).
:type parameter: str or Parameter
:type group_name: str
"""
groups = self.metadata \
.setdefault("AWS::CloudFormation::Interface", {}) \
... | [
"Add",
"a",
"parameter",
"under",
"a",
"group",
"(",
"created",
"if",
"needed",
")",
".",
":",
"type",
"parameter",
":",
"str",
"or",
"Parameter",
":",
"type",
"group_name",
":",
"str"
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/__init__.py#L725-L754 | [
"def",
"add_parameter_to_group",
"(",
"self",
",",
"parameter",
",",
"group_name",
")",
":",
"groups",
"=",
"self",
".",
"metadata",
".",
"setdefault",
"(",
"\"AWS::CloudFormation::Interface\"",
",",
"{",
"}",
")",
".",
"setdefault",
"(",
"\"ParameterGroups\"",
... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | from_file | Imports userdata from a file.
:type filepath: string
:param filepath The absolute path to the file.
:type delimiter: string
:param: delimiter Delimiter to use with the troposphere.Join().
:type blanklines: boolean
:param blanklines If blank lines shoud be ignored
rtype: troposphere... | troposphere/helpers/userdata.py | def from_file(filepath, delimiter='', blanklines=False):
"""Imports userdata from a file.
:type filepath: string
:param filepath The absolute path to the file.
:type delimiter: string
:param: delimiter Delimiter to use with the troposphere.Join().
:type blanklines: boolean
:param bla... | def from_file(filepath, delimiter='', blanklines=False):
"""Imports userdata from a file.
:type filepath: string
:param filepath The absolute path to the file.
:type delimiter: string
:param: delimiter Delimiter to use with the troposphere.Join().
:type blanklines: boolean
:param bla... | [
"Imports",
"userdata",
"from",
"a",
"file",
"."
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/helpers/userdata.py#L6-L36 | [
"def",
"from_file",
"(",
"filepath",
",",
"delimiter",
"=",
"''",
",",
"blanklines",
"=",
"False",
")",
":",
"data",
"=",
"[",
"]",
"try",
":",
"with",
"open",
"(",
"filepath",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | get_events | Get the events in batches and return in chronological order | troposphere/utils.py | def get_events(conn, stackname):
"""Get the events in batches and return in chronological order"""
next = None
event_list = []
while 1:
events = conn.describe_stack_events(stackname, next)
event_list.append(events)
if events.next_token is None:
break
next = ev... | def get_events(conn, stackname):
"""Get the events in batches and return in chronological order"""
next = None
event_list = []
while 1:
events = conn.describe_stack_events(stackname, next)
event_list.append(events)
if events.next_token is None:
break
next = ev... | [
"Get",
"the",
"events",
"in",
"batches",
"and",
"return",
"in",
"chronological",
"order"
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/utils.py#L8-L19 | [
"def",
"get_events",
"(",
"conn",
",",
"stackname",
")",
":",
"next",
"=",
"None",
"event_list",
"=",
"[",
"]",
"while",
"1",
":",
"events",
"=",
"conn",
".",
"describe_stack_events",
"(",
"stackname",
",",
"next",
")",
"event_list",
".",
"append",
"(",
... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | tail | Show and then tail the event log | troposphere/utils.py | def tail(conn, stack_name, log_func=_tail_print, sleep_time=5,
include_initial=True):
"""Show and then tail the event log"""
# First dump the full list of events in chronological order and keep
# track of the events we've seen already
seen = set()
initial_events = get_events(conn, stack_nam... | def tail(conn, stack_name, log_func=_tail_print, sleep_time=5,
include_initial=True):
"""Show and then tail the event log"""
# First dump the full list of events in chronological order and keep
# track of the events we've seen already
seen = set()
initial_events = get_events(conn, stack_nam... | [
"Show",
"and",
"then",
"tail",
"the",
"event",
"log"
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/utils.py#L22-L41 | [
"def",
"tail",
"(",
"conn",
",",
"stack_name",
",",
"log_func",
"=",
"_tail_print",
",",
"sleep_time",
"=",
"5",
",",
"include_initial",
"=",
"True",
")",
":",
"# First dump the full list of events in chronological order and keep",
"# track of the events we've seen already"... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | validate_memory_size | Validate memory size for Lambda Function
:param memory_value: The memory size specified in the Function
:return: The provided memory size if it is valid | troposphere/awslambda.py | def validate_memory_size(memory_value):
""" Validate memory size for Lambda Function
:param memory_value: The memory size specified in the Function
:return: The provided memory size if it is valid
"""
memory_value = int(positive_integer(memory_value))
if memory_value not in MEMORY_VALUES:
... | def validate_memory_size(memory_value):
""" Validate memory size for Lambda Function
:param memory_value: The memory size specified in the Function
:return: The provided memory size if it is valid
"""
memory_value = int(positive_integer(memory_value))
if memory_value not in MEMORY_VALUES:
... | [
"Validate",
"memory",
"size",
"for",
"Lambda",
"Function",
":",
"param",
"memory_value",
":",
"The",
"memory",
"size",
"specified",
"in",
"the",
"Function",
":",
"return",
":",
"The",
"provided",
"memory",
"size",
"if",
"it",
"is",
"valid"
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/awslambda.py#L28-L37 | [
"def",
"validate_memory_size",
"(",
"memory_value",
")",
":",
"memory_value",
"=",
"int",
"(",
"positive_integer",
"(",
"memory_value",
")",
")",
"if",
"memory_value",
"not",
"in",
"MEMORY_VALUES",
":",
"raise",
"ValueError",
"(",
"\"Lambda Function memory size must b... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | Override.get_validator_list | Return a list of validators specified in the override file | scripts/gen.py | def get_validator_list(self):
"""Return a list of validators specified in the override file"""
ignore = [
'dict',
]
vlist = []
if not self.override:
return vlist
for k, v in list(self.override['classes'].items()):
if 'validator' in v:
... | def get_validator_list(self):
"""Return a list of validators specified in the override file"""
ignore = [
'dict',
]
vlist = []
if not self.override:
return vlist
for k, v in list(self.override['classes'].items()):
if 'validator' in v:
... | [
"Return",
"a",
"list",
"of",
"validators",
"specified",
"in",
"the",
"override",
"file"
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L98-L119 | [
"def",
"get_validator_list",
"(",
"self",
")",
":",
"ignore",
"=",
"[",
"'dict'",
",",
"]",
"vlist",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"override",
":",
"return",
"vlist",
"for",
"k",
",",
"v",
"in",
"list",
"(",
"self",
".",
"override",
"[",... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | File._output_tags | Look for a Tags object to output a Tags import | scripts/gen.py | def _output_tags(self):
"""Look for a Tags object to output a Tags import"""
for class_name, properties in sorted(self.resources.items()):
for key, value in sorted(properties.items()):
validator = self.override.get_validator(class_name, key)
if key == 'Tags' a... | def _output_tags(self):
"""Look for a Tags object to output a Tags import"""
for class_name, properties in sorted(self.resources.items()):
for key, value in sorted(properties.items()):
validator = self.override.get_validator(class_name, key)
if key == 'Tags' a... | [
"Look",
"for",
"a",
"Tags",
"object",
"to",
"output",
"a",
"Tags",
"import"
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L164-L177 | [
"def",
"_output_tags",
"(",
"self",
")",
":",
"for",
"class_name",
",",
"properties",
"in",
"sorted",
"(",
"self",
".",
"resources",
".",
"items",
"(",
")",
")",
":",
"for",
"key",
",",
"value",
"in",
"sorted",
"(",
"properties",
".",
"items",
"(",
"... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | File._check_type | Decode a properties type looking for a specific type. | scripts/gen.py | def _check_type(self, check_type, properties):
"""Decode a properties type looking for a specific type."""
if 'PrimitiveType' in properties:
return properties['PrimitiveType'] == check_type
if properties['Type'] == 'List':
if 'ItemType' in properties:
retu... | def _check_type(self, check_type, properties):
"""Decode a properties type looking for a specific type."""
if 'PrimitiveType' in properties:
return properties['PrimitiveType'] == check_type
if properties['Type'] == 'List':
if 'ItemType' in properties:
retu... | [
"Decode",
"a",
"properties",
"type",
"looking",
"for",
"a",
"specific",
"type",
"."
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L179-L188 | [
"def",
"_check_type",
"(",
"self",
",",
"check_type",
",",
"properties",
")",
":",
"if",
"'PrimitiveType'",
"in",
"properties",
":",
"return",
"properties",
"[",
"'PrimitiveType'",
"]",
"==",
"check_type",
"if",
"properties",
"[",
"'Type'",
"]",
"==",
"'List'"... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | File._walk_for_type | Walk the resources/properties looking for a specific type. | scripts/gen.py | def _walk_for_type(self, check_type):
"""Walk the resources/properties looking for a specific type."""
for class_name, properties in sorted(self.resources.items()):
for key, value in sorted(properties.items()):
if self._check_type(check_type, value):
retur... | def _walk_for_type(self, check_type):
"""Walk the resources/properties looking for a specific type."""
for class_name, properties in sorted(self.resources.items()):
for key, value in sorted(properties.items()):
if self._check_type(check_type, value):
retur... | [
"Walk",
"the",
"resources",
"/",
"properties",
"looking",
"for",
"a",
"specific",
"type",
"."
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L190-L201 | [
"def",
"_walk_for_type",
"(",
"self",
",",
"check_type",
")",
":",
"for",
"class_name",
",",
"properties",
"in",
"sorted",
"(",
"self",
".",
"resources",
".",
"items",
"(",
")",
")",
":",
"for",
"key",
",",
"value",
"in",
"sorted",
"(",
"properties",
"... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | File._get_type_list | Return a list of non-primitive types used by this object. | scripts/gen.py | def _get_type_list(self, props):
"""Return a list of non-primitive types used by this object."""
type_list = []
for k, v in list(props.items()):
t = self._get_property_type(v)
if t is not None:
type_list.append(t)
return sorted(type_list) | def _get_type_list(self, props):
"""Return a list of non-primitive types used by this object."""
type_list = []
for k, v in list(props.items()):
t = self._get_property_type(v)
if t is not None:
type_list.append(t)
return sorted(type_list) | [
"Return",
"a",
"list",
"of",
"non",
"-",
"primitive",
"types",
"used",
"by",
"this",
"object",
"."
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L218-L225 | [
"def",
"_get_type_list",
"(",
"self",
",",
"props",
")",
":",
"type_list",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"list",
"(",
"props",
".",
"items",
"(",
")",
")",
":",
"t",
"=",
"self",
".",
"_get_property_type",
"(",
"v",
")",
"if",
"t",
... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | File._output_validators | Output common validator types based on usage. | scripts/gen.py | def _output_validators(self):
"""Output common validator types based on usage."""
if self._walk_for_type('Boolean'):
print("from .validators import boolean")
if self._walk_for_type('Integer'):
print("from .validators import integer")
vlist = self.override.get_vali... | def _output_validators(self):
"""Output common validator types based on usage."""
if self._walk_for_type('Boolean'):
print("from .validators import boolean")
if self._walk_for_type('Integer'):
print("from .validators import integer")
vlist = self.override.get_vali... | [
"Output",
"common",
"validator",
"types",
"based",
"on",
"usage",
"."
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L227-L240 | [
"def",
"_output_validators",
"(",
"self",
")",
":",
"if",
"self",
".",
"_walk_for_type",
"(",
"'Boolean'",
")",
":",
"print",
"(",
"\"from .validators import boolean\"",
")",
"if",
"self",
".",
"_walk_for_type",
"(",
"'Integer'",
")",
":",
"print",
"(",
"\"fro... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | File.build_tree | Build a tree of non-primitive typed dependency order. | scripts/gen.py | def build_tree(self, name, props, resource_name=None):
"""Build a tree of non-primitive typed dependency order."""
n = Node(name, props, resource_name)
prop_type_list = self._get_type_list(props)
if not prop_type_list:
return n
prop_type_list = sorted(prop_type_list)
... | def build_tree(self, name, props, resource_name=None):
"""Build a tree of non-primitive typed dependency order."""
n = Node(name, props, resource_name)
prop_type_list = self._get_type_list(props)
if not prop_type_list:
return n
prop_type_list = sorted(prop_type_list)
... | [
"Build",
"a",
"tree",
"of",
"non",
"-",
"primitive",
"typed",
"dependency",
"order",
"."
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L249-L262 | [
"def",
"build_tree",
"(",
"self",
",",
"name",
",",
"props",
",",
"resource_name",
"=",
"None",
")",
":",
"n",
"=",
"Node",
"(",
"name",
",",
"props",
",",
"resource_name",
")",
"prop_type_list",
"=",
"self",
".",
"_get_type_list",
"(",
"props",
")",
"... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | File.output_tree | Given a dependency tree of objects, output it in DFS order. | scripts/gen.py | def output_tree(self, t, seen):
"""Given a dependency tree of objects, output it in DFS order."""
if not t:
return
for c in t.children:
self.output_tree(c, seen)
if t.name in seen:
return
seen[t.name] = True
if t.resource_name:
... | def output_tree(self, t, seen):
"""Given a dependency tree of objects, output it in DFS order."""
if not t:
return
for c in t.children:
self.output_tree(c, seen)
if t.name in seen:
return
seen[t.name] = True
if t.resource_name:
... | [
"Given",
"a",
"dependency",
"tree",
"of",
"objects",
"output",
"it",
"in",
"DFS",
"order",
"."
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L264-L276 | [
"def",
"output_tree",
"(",
"self",
",",
"t",
",",
"seen",
")",
":",
"if",
"not",
"t",
":",
"return",
"for",
"c",
"in",
"t",
".",
"children",
":",
"self",
".",
"output_tree",
"(",
"c",
",",
"seen",
")",
"if",
"t",
".",
"name",
"in",
"seen",
":",... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | File.output | Output the generated source file. | scripts/gen.py | def output(self):
"""Output the generated source file."""
print(copyright_header % spec_version)
self._output_imports()
self._output_tags()
self._output_validators()
header = self.override.get_header()
if header:
print()
print()
... | def output(self):
"""Output the generated source file."""
print(copyright_header % spec_version)
self._output_imports()
self._output_tags()
self._output_validators()
header = self.override.get_header()
if header:
print()
print()
... | [
"Output",
"the",
"generated",
"source",
"file",
"."
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/scripts/gen.py#L278-L294 | [
"def",
"output",
"(",
"self",
")",
":",
"print",
"(",
"copyright_header",
"%",
"spec_version",
")",
"self",
".",
"_output_imports",
"(",
")",
"self",
".",
"_output_tags",
"(",
")",
"self",
".",
"_output_validators",
"(",
")",
"header",
"=",
"self",
".",
... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | TemplateGenerator.inspect_members | Returns the list of all troposphere members we are able to
construct | troposphere/template_generator.py | def inspect_members(self):
"""
Returns the list of all troposphere members we are able to
construct
"""
if not self._inspect_members:
TemplateGenerator._inspect_members = \
self._import_all_troposphere_modules()
return self._inspect_members | def inspect_members(self):
"""
Returns the list of all troposphere members we are able to
construct
"""
if not self._inspect_members:
TemplateGenerator._inspect_members = \
self._import_all_troposphere_modules()
return self._inspect_members | [
"Returns",
"the",
"list",
"of",
"all",
"troposphere",
"members",
"we",
"are",
"able",
"to",
"construct"
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L78-L86 | [
"def",
"inspect_members",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_inspect_members",
":",
"TemplateGenerator",
".",
"_inspect_members",
"=",
"self",
".",
"_import_all_troposphere_modules",
"(",
")",
"return",
"self",
".",
"_inspect_members"
] | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | TemplateGenerator.inspect_resources | Returns a map of `ResourceType: ResourceClass` | troposphere/template_generator.py | def inspect_resources(self):
""" Returns a map of `ResourceType: ResourceClass` """
if not self._inspect_resources:
d = {}
for m in self.inspect_members:
if issubclass(m, (AWSObject, cloudformation.AWSCustomObject)) \
and hasattr(m, 'resour... | def inspect_resources(self):
""" Returns a map of `ResourceType: ResourceClass` """
if not self._inspect_resources:
d = {}
for m in self.inspect_members:
if issubclass(m, (AWSObject, cloudformation.AWSCustomObject)) \
and hasattr(m, 'resour... | [
"Returns",
"a",
"map",
"of",
"ResourceType",
":",
"ResourceClass"
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L89-L100 | [
"def",
"inspect_resources",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_inspect_resources",
":",
"d",
"=",
"{",
"}",
"for",
"m",
"in",
"self",
".",
"inspect_members",
":",
"if",
"issubclass",
"(",
"m",
",",
"(",
"AWSObject",
",",
"cloudformation",... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
train | TemplateGenerator.inspect_functions | Returns a map of `FunctionName: FunctionClass` | troposphere/template_generator.py | def inspect_functions(self):
""" Returns a map of `FunctionName: FunctionClass` """
if not self._inspect_functions:
d = {}
for m in self.inspect_members:
if issubclass(m, AWSHelperFn):
d[m.__name__] = m
TemplateGenerator._inspect_f... | def inspect_functions(self):
""" Returns a map of `FunctionName: FunctionClass` """
if not self._inspect_functions:
d = {}
for m in self.inspect_members:
if issubclass(m, AWSHelperFn):
d[m.__name__] = m
TemplateGenerator._inspect_f... | [
"Returns",
"a",
"map",
"of",
"FunctionName",
":",
"FunctionClass"
] | cloudtools/troposphere | python | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L103-L113 | [
"def",
"inspect_functions",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_inspect_functions",
":",
"d",
"=",
"{",
"}",
"for",
"m",
"in",
"self",
".",
"inspect_members",
":",
"if",
"issubclass",
"(",
"m",
",",
"AWSHelperFn",
")",
":",
"d",
"[",
"... | f7ea5591a7c287a843adc9c184d2f56064cfc632 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.