下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。
内存溢出小编现在分享给大家,也给大家做个参考。
import libvirtimport osimport uuIDtry: from PIL import Image print("PIL")except importError: import Imagedef handler(stream,buf,opaque): fd = opaque os.write(fd,buf)thumbnail_SIZE =(256,256)thumbnail = '/home/hcc/test/screenshot/test-' + str(uuID.uuID4())command = "touch " + thumbnailprint(command)os.system(command)fd = os.open(thumbnail,os.O_WRONLY | os.O_Trunc | os.O_CREAT,0644)try: conn = libvirt.open('qemu:///system') d1 = conn.lookupByname('test') print(d1.info()) print(d1.name()) stream = conn.newStream(0) d1.screenshot(stream,0) stream.recvAll(handler,fd) if os.path.getsize(thumbnail) == 0: image = Image.new("RGB",thumbnail_SIZE,'black') image.save(thumbnail) else: print("else") im = Image.open(thumbnail) im.thumbnail(thumbnail_SIZE) im.save(thumbnail,'PNG')except libvirt.libvirtError: try: stream.abor() except: passelse: stream.finish()finally: os.close(fd)
以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
总结以上是内存溢出为你收集整理的使用libvirt抓取linux kvm虚拟机的缩略图全部内容,希望文章能够帮你解决使用libvirt抓取linux kvm虚拟机的缩略图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)