Change in ...osmo-python-tests[master]: vty.py: Fix endl removed when pkt buffer content ends exactly on a ne...

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/.

pespin gerrit-no-reply at lists.osmocom.org
Fri Aug 23 13:52:43 UTC 2019


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/15274


Change subject: vty.py: Fix endl removed when pkt buffer content ends exactly on a newline char
......................................................................

vty.py: Fix endl removed when pkt buffer content ends exactly on a newline char

As a result, osmo_interact_vty.py was printing incorrect output:
"""
-        <param name='shutdown' doc='Remove the APN from administrative shut-down' />
-      </params>
+        <param name='shutdown' doc='Remove the APN from administrative shut-down' />      </params
"""

Change-Id: Ib1dbf39db1b27331ea4c39051e550a87780d9f76
---
M osmopy/osmo_interact/vty.py
1 file changed, 10 insertions(+), 3 deletions(-)



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

diff --git a/osmopy/osmo_interact/vty.py b/osmopy/osmo_interact/vty.py
index e66ed22..f4b9aff 100755
--- a/osmopy/osmo_interact/vty.py
+++ b/osmopy/osmo_interact/vty.py
@@ -116,9 +116,16 @@
                 # 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]
+                last_line = last_line.replace('\r', '')
+                lines = last_line.splitlines()
+                if last_line.endswith('\n'):
+                    received_lines.extend(lines)
+                    last_line = ""
+                else:
+                    # if pkt buffer ends in the middle of a line, we need to keep
+                    # last non-finished line:
+                    received_lines.extend(lines[:-1])
+                    last_line = lines[-1]
 
             match = self.re_prompt.match(last_line)
             if not match:

-- 
To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/15274
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Change-Id: Ib1dbf39db1b27331ea4c39051e550a87780d9f76
Gerrit-Change-Number: 15274
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190823/97dabde6/attachment.htm>


More information about the gerrit-log mailing list