def capture(self, data, term_instance=None):
"""
Stores *data* as a temporary file and returns that file's object.
*term_instance* can be used by overrides of this function to make
adjustments to the terminal emulator after the *data* is captured e.g.
to make room for an image.
"""
# Remove the extra \r's that the terminal adds:
data = data.replace(b'\r\n', b'\n')
logging.debug("capture() len(data): %s" % len(data))
# Write the data to disk in a temporary location
self.file_obj = tempfile.TemporaryFile()
self.file_obj.write(data)
self.file_obj.flush()
# Leave it open
return self.file_obj
评论列表
文章目录