aboutsummaryrefslogtreecommitdiffstats
path: root/osmopy
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-08-23 15:51:33 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-08-23 15:54:27 +0200
commitc6f8d553376d78631e7e40286911bb8025263591 (patch)
treec46bc4062e28233bd196e0b83cef56687e155154 /osmopy
parentff0607cbf783e2622fed0a6b9d11d8978cd34520 (diff)
vty.py: Fix endl removed when pkt buffer content ends exactly on a newline charosmith/before-py2-drop
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
Diffstat (limited to 'osmopy')
-rwxr-xr-xosmopy/osmo_interact/vty.py13
1 files changed, 10 insertions, 3 deletions
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 @@ class InteractVty(Interact):
# 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: