VirtualBox api :“take_screen_shot_to_array” function raise an unicode error only with python3, how to access XPCOMObject method to debug?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 15:37:37

问题


The following code work fine in python2.7, but with python3.6,

import virtualbox
vbox = virtualbox.VirtualBox()
vm = vbox.find_machine("my_vbox_machine_name")
session = vm.create_session()
display = session.console.display
png = display.take_screen_shot_to_array(0,10,10,virtualbox.library.BitmapFormat.png)

it's end with this error :

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/username/.local/lib/python3.6/site-packages/virtualbox/library.py", line 23684, in take_screen_shot_to_array
    in_p=[screen_id, width, height, bitmap_format])  
  File "/home/username/.local/lib/python3.6/site-packages/virtualbox/library_base.py", line 190, in _call
    return self._call_method(method, in_p=in_p)
  File "/home/username/.local/lib/python3.6/site-packages/virtualbox/library_base.py", line 231, in _call_method
    ret = method(*in_params)
  File "<XPCOMObject method 'takeScreenShotToArray'>", line 3, in takeScreenShotToArray
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte

I expect it is due to the difference of the string object between python2 and python3 version.


I am use to see a real file path in the python trackback "File" field, but this time it is not, so I am little bit disappointed ...

I would to patch this, but I don't know how to access the file: <XPCOMObject method 'takeScreenShotToArray'> ?

来源:https://stackoverflow.com/questions/55088041/virtualbox-api-take-screen-shot-to-array-function-raise-an-unicode-error-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!