Checks if the device is in configuration mode or not. :param check_string: Identification of configuration mode from the device :type check_string: str :param pattern: Pattern to terminate reading of channel :type pattern: str :param force_regex: Use regula
(
self, check_string: str = "", pattern: str = "", force_regex: bool = False
)
| 2093 | return output |
| 2094 | |
| 2095 | def check_config_mode( |
| 2096 | self, check_string: str = "", pattern: str = "", force_regex: bool = False |
| 2097 | ) -> bool: |
| 2098 | """Checks if the device is in configuration mode or not. |
| 2099 | |
| 2100 | :param check_string: Identification of configuration mode from the device |
| 2101 | :type check_string: str |
| 2102 | |
| 2103 | :param pattern: Pattern to terminate reading of channel |
| 2104 | :type pattern: str |
| 2105 | |
| 2106 | :param force_regex: Use regular expression pattern to find check_string in output |
| 2107 | :type force_regex: bool |
| 2108 | |
| 2109 | """ |
| 2110 | self.write_channel(self.RETURN) |
| 2111 | # You can encounter an issue here (on router name changes) prefer delay-based solution |
| 2112 | if not pattern: |
| 2113 | output = self.read_channel_timing(read_timeout=10.0) |
| 2114 | else: |
| 2115 | output = self.read_until_pattern(pattern=pattern) |
| 2116 | |
| 2117 | if force_regex: |
| 2118 | return bool(re.search(check_string, output)) |
| 2119 | else: |
| 2120 | return check_string in output |
| 2121 | |
| 2122 | def config_mode(self, config_command: str = "", pattern: str = "", re_flags: int = 0) -> str: |
| 2123 | """Enter into config_mode. |
no test coverage detected