Change in python/osmo-python-tests[master]: osmo_interact/vty.py: fix parsing of vty logging

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Sep 10 13:54:48 UTC 2018


Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/10865


Change subject: osmo_interact/vty.py: fix parsing of vty logging
......................................................................

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
---
M osmopy/osmo_interact/vty.py
1 file changed, 7 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/65/10865/1

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 @@
             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]
 

-- 
To view, visit https://gerrit.osmocom.org/10865
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8de9cebaa9aad275f65c3672985b7cbca343b5a6
Gerrit-Change-Number: 10865
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180910/f6b82d4c/attachment.htm>


More information about the gerrit-log mailing list