Skip to content

Commit 7395011

Browse files
fix: Fix pattern to handle long system identity (#386)
* fix: Fix pattern to handle long system identity names When the system identity string is too long, the terminal output may be truncated. The truncated output is marked by multiple carriage returns (`\r`) and a `<` symbol. This is a example of a truncated output: `\r\n\r\r\r\r<MY_VERYVERY-LONG-SYSTEM-IDENTIY-NAME] > ` The existing regex failed to match these truncated prompts. This update introduces a more flexible regex that matches both, the truncated and the preserved output. * add change-log fragment for pr 386 * refactoring change-log fragment for pr 386 * Update changelogs/fragments/386-fix-pattern-to-handle-long-identity.yml Co-authored-by: Felix Fontein <[email protected]> --------- Co-authored-by: Felix Fontein <[email protected]>
1 parent 8edc801 commit 7395011

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
bugfixes:
3+
- routeros terminal plugin - fix ``terminal_stdout_re`` pattern to handle long system identities when connecting to RouterOS through SSH (https://github.com/ansible-collections/community.routeros/pull/386).

plugins/terminal/routeros.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ class TerminalModule(TerminalBase):
3131

3232
terminal_stdout_re = [
3333
re.compile(br"\x1b<"),
34-
re.compile(br"\[[\w\-\.]+\@[\w\s\-\.\/]+\] ?(<SAFE)?> ?$"),
34+
re.compile(
35+
br"((\[[\w\-\.]+\@)|(\r\<(([\w\-\.]*\@)|)))"
36+
br"[\w\s\-\.\/]+\] ?(<SAFE)?> ?$"),
3537
re.compile(br"Please press \"Enter\" to continue!"),
3638
re.compile(br"Do you want to see the software license\? \[Y\/n\]: ?"),
3739
]

0 commit comments

Comments
 (0)