# # # patch "mtn.py" # from [8c6acc980241b776980561ea90b7b4d87f01db76] # to [928e6014f2482f0a10cd1a9d2d586fa6f9f11261] # ============================================================ --- mtn.py 8c6acc980241b776980561ea90b7b4d87f01db76 +++ mtn.py 928e6014f2482f0a10cd1a9d2d586fa6f9f11261 @@ -59,7 +59,7 @@ class Automate(Runner): return terminate_popen3(self.process) self.process = None - + def __process_required(self): if self.process != None: return @@ -139,11 +139,22 @@ class Automate(Runner): # get our response, and yield() it back one line at a time code_max = -1 + data_buf = '' for code, is_last, data in read_result_packets(): + debug((code, is_last, data)) if code and code > code_max: code_max = code - for line in data.split('\n'): - yield line + '\n' + data_buf += data + while True: + idx = data_buf.find('\n') + if idx == -1: + break + debug(('yielding', data_buf[:idx])) + yield data_buf[:idx] + data_buf = data_buf[idx+1:] + # left over data? + if data_buf: + yield data_buf if code_max > 0: raise MonotoneException("error code %d in automate packet." % (code_max)) @@ -298,6 +309,7 @@ class Operations: yield line def get_revision(self, revision): + debug(map(None, self.automate.run('get_revision', [revision]))) for stanza in basic_io_from_stream(self.automate.run('get_revision', [revision])): yield stanza