Adding updates for python3 compatibility and new virtualbox SDK version support.

This commit is contained in:
Chris Smith 2018-04-18 17:09:39 -05:00 committed by smitty42
parent cebcd6d069
commit 91252bac95
No known key found for this signature in database
GPG key ID: F880F59CE65D08F4

View file

@ -132,6 +132,12 @@ def vb_get_manager():
'''
global _virtualboxManager
if _virtualboxManager is None and HAS_LIBS:
try:
from importlib import reload
except ImportError:
# If we get here, we are in py2 and reload is a built-in.
pass
# Reloading the API extends sys.paths for subprocesses of multiprocessing, since they seem to share contexts
reload(vboxapi)
_virtualboxManager = vboxapi.VirtualBoxManager(None, None)
@ -146,7 +152,13 @@ def vb_get_box():
@rtype: IVirtualBox
'''
vb_get_manager()
vbox = _virtualboxManager.vbox
try:
# This works in older versions of the SDK, but does not seem to work anymore.
vbox = _virtualboxManager.vbox
except AttributeError:
vbox = _virtualboxManager.getVirtualBox()
return vbox