virtualbox-python
virtualbox-python copied to clipboard
TypeError in launch_vm_process
ENVIRONMENT
- virtualbox-python / pyvbox version: 2.2.1
SUMMARY
Function launch_vm_process in library.py has input parameter 'environment_changes' that is list in the last version.
if not isinstance(environment_changes, list):
raise TypeError("environment_changes can only be an instance of type list")
But in library_ext/machine.py method launch_vm_process of class IMachine has input parameter 'environment' which is string by default. So call launch_vm_process() for machine with default arguments leads to TypeError exception.
Also need to update comment in library.py (str -> list):
in environment_changes of type str
The list of putenv-style changes to the VM process environment.
STEPS TO REPRODUCE
vbox = virtualbox.VirtualBox()
vm = vbox.find_machine(vm_name)
p = vm.launch_vm_process()
EXPECTED RESULTS
No exception
ACTUAL RESULTS
Traceback (most recent call last):
File "build/bdist.macosx-10.15-x86_64/egg/test_service/vm_utils.py", line 203, in start_vm
p = vm.launch_vm_process()
File "/Users/test/Library/Python/2.7/lib/python/site-packages/virtualbox/library_ext/machine.py", line 189, in launch_vm_process
p = super(IMachine, self).launch_vm_process(local_session, type_p, environment)
File "/Users/test/Library/Python/2.7/lib/python/site-packages/virtualbox/library.py", line 15345, in launch_vm_process
raise TypeError("environment_changes can only be an instance of type list")
TypeError: environment_changes can only be an instance of type list
Could you submit a PR? Maybe within library_ext/machine.py
we can support both string and list.
I'll submit PR but right now I'm trying to understand of which data type environment argument should be.
As I see earlier environment supported both string and list:
if not (isinstance(environment, basestring) or isinstance(environment, list)):
raise TypeError("environment can only be an instance of type basestring or list")
And it was necessary to explicitly provide the value. From README.rst:
>>> # progress = machine.launch_vm_process(session, "gui", "")
>>> # For virtualbox API 6_1 and above (VirtualBox 6.1.2+), use the following:
>>> progress = machine.launch_vm_process(session, "gui", [])
Now argument have to be only list:
if not isinstance(environment_changes, list):
raise TypeError("environment_changes can only be an instance of type list")
Does this change mean that virtualbox_sdk < 6.1.2 is not supported any more?
@dr0ndv I'd like to support v6.1.2 still, however virtualbox/library.py
is generated completely from the upstream API spec so we can only do so much. Any changes we want to do should be in library_ext
, maybe we can map any input of type str
to a list?
#154 Let's continue discussion in PR