Skip to content

Commit c059d36

Browse files
committed
Ready for final review :)
1 parent 6bbe21f commit c059d36

File tree

1 file changed

+21
-34
lines changed

1 file changed

+21
-34
lines changed

netmiko/hioso/hioso.py

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,62 +5,49 @@
55

66

77
class HiosoBase(CiscoBaseConnection):
8+
"""
9+
Base class for Hioso devices.
10+
It is fairly similar to Cisco devices.
11+
"""
12+
813
prompt_pattern = r"[\]>]"
9-
password_change_prompt = r"(?:Change now|Please choose)"
1014
prompt_or_password_change = rf"(?:Change now|Please choose|{prompt_pattern})"
1115

1216
def session_preparation(self) -> None:
13-
"""Prepare the session after the connection has been established."""
17+
"""Prepare the session after the connection is established."""
1418
self.ansi_escape_codes = True
15-
# The _test_channel_read happens in special_login_handler()
1619
self.set_base_prompt()
1720
self.enable()
18-
self.disable_paging(command="terminal length 0")
19-
self.find_prompt() # The disable_paging doesn't clear the buffer
20-
self.exit_enable_mode(exit_command="exit")
21-
22-
def config_mode(
23-
self,
24-
config_command: str = "configure terminal",
25-
pattern: str = "",
26-
re_flags: int = 0,
27-
) -> str:
28-
return super().config_mode(
29-
config_command=config_command, pattern=pattern, re_flags=re_flags
30-
)
31-
32-
def exit_config_mode(
33-
self,
34-
exit_config: str = "exit",
35-
pattern: str = r"#"
36-
) -> str:
37-
"""Exit configuration mode."""
38-
return super().exit_config_mode(
39-
exit_config=exit_config, pattern=pattern
40-
)
21+
self.disable_paging()
22+
self.clear_buffer()
23+
self.exit_enable_mode()
4124

4225
def check_config_mode(
4326
self,
44-
check_string: str = ")",
45-
pattern: str = "",
46-
force_regex: bool = False
27+
check_string: str = ")#",
28+
pattern: str = r"[>#]",
29+
force_regex: bool = False,
4730
) -> bool:
48-
"""Checks whether in configuration mode. Returns a boolean."""
49-
return super().check_config_mode(check_string=check_string)
31+
return super().check_config_mode(check_string, pattern, force_regex)
32+
33+
def exit_config_mode(self, exit_config: str = "exit", pattern: str = r"#") -> str:
34+
"""Exit configuration mode."""
35+
return super().exit_config_mode(exit_config=exit_config, pattern=pattern)
5036

5137
def save_config(
5238
self,
5339
cmd: str = "write file",
5440
confirm: bool = False,
55-
confirm_response: str = "y"
41+
confirm_response: str = "y",
5642
) -> str:
5743
"""Save Config for Hioso Telnet."""
5844
return super().save_config(
5945
cmd=cmd, confirm=confirm, confirm_response=confirm_response
6046
)
6147

6248
def cleanup(self, command: str = "quit") -> None:
63-
return super().cleanup(command=command)
49+
"""Cleanup the connection."""
50+
super().cleanup(command=command)
6451

6552

6653
class HiosoTelnet(HiosoBase):
@@ -75,7 +62,7 @@ def telnet_login(
7562
delay_factor: float = 1.0,
7663
max_loops: int = 20,
7764
) -> str:
78-
"""Telnet login for Huawei Devices"""
65+
"""Telnet login for Hioso Devices"""
7966
output = ""
8067
return_msg = ""
8168
try:

0 commit comments

Comments
 (0)