aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-09-10 15:44:45 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-09-10 15:50:08 +0200
commitb0621451e391203eed062dee54c2279e6fe3335c (patch)
treea705b762d395a693108f7b791cc6f6b07d82d71f
parent4c8a0bdc398ed2c71609b27afe81892097e64f05 (diff)
osmo_interact/vty.py: fix parsing of vty logging
Because the VTY logging target currently prints '\n\r' instead of '\r\n', the python splitlines() separates those as interleaving empty lines. Ignore '\r' to allow verifying VTY logging output as well. Change-Id: I8de9cebaa9aad275f65c3672985b7cbca343b5a6
-rwxr-xr-xosmopy/osmo_interact/vty.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/osmopy/osmo_interact/vty.py b/osmopy/osmo_interact/vty.py
index 4704c09..e66ed22 100755
--- a/osmopy/osmo_interact/vty.py
+++ b/osmopy/osmo_interact/vty.py
@@ -110,7 +110,13 @@ class InteractVty(Interact):
last_line = "%s%s" % (last_line, new_data)
if last_line:
- lines = last_line.splitlines()
+ # Separate the received response into lines.
+ # But note: the VTY logging currently separates with '\n\r', not '\r\n',
+ # see _vty_output() in libosmocore logging_vty.c.
+ # So we need to jump through hoops to not separate 'abc\n\rdef' as
+ # [ 'abc', '', 'def' ]; but also not to convert '\r\n\r\n' to '\r\n\n' ('\r{\r\n}\n')
+ # Simplest is to just drop all the '\r' and only care about the '\n'.
+ lines = last_line.replace('\r', '').splitlines()
received_lines.extend(lines[:-1])
last_line = lines[-1]