Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pagination support #3395

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions netmiko/base_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def __init__(
auto_connect: bool = True,
delay_factor_compat: bool = False,
disable_lf_normalization: bool = False,
next_page_string: Optional[str] = None,
) -> None:
"""
Initialize attributes for establishing connection to target device.
Expand Down Expand Up @@ -376,6 +377,7 @@ def __init__(
self._legacy_mode = _legacy_mode
self.global_delay_factor = global_delay_factor
self.global_cmd_verify = global_cmd_verify
self.next_page_string = next_page_string
if self.fast_cli and self.global_delay_factor == 1:
self.global_delay_factor = 0.1
self.session_log = None
Expand Down Expand Up @@ -1767,6 +1769,7 @@ def send_command(
# Start the clock
start_time = time.time()
self.write_channel(command_string)

new_data = ""

cmd = command_string.strip()
Expand Down Expand Up @@ -1808,7 +1811,14 @@ def send_command(
break

time.sleep(loop_delay)
new_data = self.read_channel()
read_channel_data = self.read_channel()
if self.next_page_string:
if re.search(self.next_page_string, read_channel_data):
self.write_channel(" ")
time.sleep(0.5)
new_data = re.sub(self.next_page_string, '', read_channel_data)
else:
new_data = read_channel_data

else: # nobreak
msg = f"""
Expand Down Expand Up @@ -1933,14 +1943,21 @@ def strip_command(self, command_string: str, output: str) -> str:
"""
Strip command_string from output string

Cisco IOS adds backspaces into output for long commands (i.e. for commands that line wrap)

:param command_string: The command string sent to the device
:type command_string: str

:param output: The returned output as a result of the command string sent to the device
:type output: str
"""
# ruckus netiron adds backspaces with space for pagination output
backspace_char = "\x08 "

# Check for line wrap (remove backspaces)
if backspace_char in output:
output = output.replace(backspace_char, "")

# Cisco IOS adds backspaces into output for long commands (i.e. for commands that line wrap)
backspace_char = "\x08"

# Check for line wrap (remove backspaces)
Expand Down
2 changes: 0 additions & 2 deletions netmiko/ruckus/ruckus_fastiron.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def session_preparation(self) -> None:
"""FastIron requires to be enable mode to disable paging."""
self._test_channel_read()
self.set_base_prompt()
self.enable()
self.disable_paging(command="skip-page-display")
# Clear the read buffer
time.sleep(0.3 * self.global_delay_factor)
self.clear_buffer()
Expand Down