From f765980313a6a2e6466aa4ddff70a1278462e5aa Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Wed, 12 Apr 2006 01:43:27 -0700 Subject: [PATCH] [project @ robey@lag.net-20060412084327-0d666ca96c0b0976] oops, don't forget to add the empty() method --- paramiko/buffered_pipe.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/paramiko/buffered_pipe.py b/paramiko/buffered_pipe.py index eb33734..ab89675 100644 --- a/paramiko/buffered_pipe.py +++ b/paramiko/buffered_pipe.py @@ -154,6 +154,23 @@ class BufferedPipe (object): return out + def empty(self): + """ + Clear out the buffer and return all data that was in it. + + @return: any data that was in the buffer prior to clearing it out + @rtype: str + """ + self._lock.acquire() + try: + out = self._buffer.tostring() + del self._buffer[:] + if (self._event is not None) and not self._closed: + self._event.clear() + return out + finally: + self._lock.release() + def close(self): """ Close this pipe object. Future calls to L{read} after the buffer