问题
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