Skip to content

Commit

Permalink
Change some of special message logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers committed Jul 8, 2024
1 parent d914695 commit 4d7fcc3
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions netmiko/mikrotik/mikrotik_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MikrotikBase(NoEnable, NoConfig, CiscoSSHConnection):
def __init__(self, **kwargs: Any) -> None:
if kwargs.get("default_enter") is None:
kwargs["default_enter"] = "\r\n"
self.default_enter = kwargs["default_enter"]

return super().__init__(**kwargs)

def special_login_handler(self, delay_factor: float = 1.0) -> None:
Expand All @@ -34,16 +34,14 @@ def special_login_handler(self, delay_factor: float = 1.0) -> None:
)

data = self.read_until_pattern(pattern=combined_pattern, re_flags=re.I)

# Handle "no license" message
if no_license_message in data:
self.write_channel(self.default_enter)
data = self.read_until_pattern(pattern=combined_pattern, re_flags=re.I)

# Handle software license prompt
if license_prompt in data:
# Handle "no license" message
self.write_channel(self.default_enter) # type: ignore
self.read_until_pattern(pattern=self.prompt_pattern)
elif license_prompt in data:
# Handle software license prompt
self.write_channel("n")
data = self.read_until_pattern(pattern=self.prompt_pattern, re_flags=re.I)
self.read_until_pattern(pattern=self.prompt_pattern)

def session_preparation(self, *args: Any, **kwargs: Any) -> None:
"""Prepare the session after the connection has been established."""
Expand Down

0 comments on commit 4d7fcc3

Please sign in to comment.