

def ex_take_node_screenshot(self, node, directory, screen=0):
    '\n        Take a screenshot of a monitoring of a running instance.\n\n        :param node: Node to take the screenshot of.\n        :type node: :class:`libcloud.compute.base.Node`\n\n        :param directory: Path where the screenshot will be saved.\n        :type directory: ``str``\n\n        :param screen: ID of the monitor to take the screenshot of.\n        :type screen: ``int``\n\n        :return: Full path where the screenshot has been saved.\n        :rtype: ``str``\n        '
    if ((not os.path.exists(directory)) or (not os.path.isdir(directory))):
        raise ValueError('Invalid value for directory argument')
    domain = self._get_domain_for_node(node=node)
    stream = self.connection.newStream()
    mime_type = domain.screenshot(stream=stream, screen=0)
    extensions = mimetypes.guess_all_extensions(type=mime_type)
    if extensions:
        extension = extensions[0]
    else:
        extension = '.png'
    name = ('screenshot-%s%s' % (int(time.time()), extension))
    file_path = pjoin(directory, name)
    with open(file_path, 'wb') as fp:

        def write(stream, buf, opaque):
            fp.write(buf)
        mime_type.recvAll(write, None)
    try:
        stream.finish()
    except Exception:
        pass
    return file_path

dataset/ETHPy150Open apache/libcloud/libcloud/compute/drivers/libvirt_driver.py LibvirtNodeDriver.ex_take_node_screenshot/VarMisuse@186/411 `stream`->`mime_type`