def screenshot(context):
    """Takes a screenshot of the vnc connection of the guest.
    The resulting image file will be in Portable Pixmap format (PPM).

    @param context: (see.Context) context of the Environment.
    @return: (str) binary stream containing the screenshot.

    """
    handler = lambda _, buff, file_handler: file_handler.write(buff)

    string = BytesIO()
    stream = context.domain.connect().newStream(0)
    context.domain.screenshot(stream, 0, 0)
    stream.recvAll(handler, string)

    return string.getvalue()