Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bareos/python-bareos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bareos/bsock/lowlevel.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/bareos/bsock/lowlevel.py b/bareos/bsock/lowlevel.py
index 042fa68..61b9edb 100644
--- a/bareos/bsock/lowlevel.py
+++ b/bareos/bsock/lowlevel.py
@@ -195,13 +195,18 @@ class LowLevel(object):
else:
# header is the length of the next message
length = header
- self.receive_buffer += self.recv_submsg(length)
+ submsg = self.recv_submsg(length)
+ # check for regex in new submsg
+ # and last line in old message,
+ # which might have been incomplete without new submsg.
+ lastlineindex = self.receive_buffer.rfind('\n') + 1
+ self.receive_buffer += submsg
+ match = re.search(regex, self.receive_buffer[lastlineindex:], re.MULTILINE)
# Bareos indicates end of command result by line starting with 4 digits
- match = re.search(regex, self.receive_buffer, re.MULTILINE)
if match:
self.logger.debug("msg \"{0}\" matches regex \"{1}\"".format(self.receive_buffer.strip(), regex))
- result = self.receive_buffer[0:match.end()]
- self.receive_buffer = self.receive_buffer[match.end()+1:]
+ result = self.receive_buffer[0:lastlineindex] + self.receive_buffer[lastlineindex:match.end()]
+ self.receive_buffer = self.receive_buffer[lastlineindex+match.end()+1:]
return result
#elif re.search("^\d\d\d\d .*$", msg, re.MULTILINE):
#return msg