Update workaround to root of file

This commit is contained in:
Mark Gomersbach 2018-10-19 14:44:59 +02:00
parent 253ab11bd9
commit 37ab1f84b8
No known key found for this signature in database
GPG Key ID: B5171AF93EC64F16
2 changed files with 20 additions and 34 deletions

View File

@ -19,6 +19,14 @@ from __future__ import absolute_import
import copy
import logging
import re
try:
if globals()['__builtins__'].reload:
pass
except AttributeError:
try:
from importlib import reload
except ImportError:
from imp import reload
# Import salt libs
import salt.utils
@ -61,29 +69,13 @@ def __virtual__():
def _vartree():
import portage # pylint: disable=3rd-party-module-not-gated
try:
reload(portage)
except NameError:
try:
from importlib import reload
reload(portage)
except ImportError:
from imp import reload
reload(portage)
reload(portage)
return portage.db[portage.root]['vartree']
def _porttree():
import portage # pylint: disable=3rd-party-module-not-gated
try:
reload(portage)
except NameError:
try:
from importlib import reload
reload(portage)
except ImportError:
from imp import reload
reload(portage)
reload(portage)
return portage.db[portage.root]['porttree']

View File

@ -13,6 +13,15 @@ import logging
import re
import time
try:
if globals()['__builtins__'].reload:
pass
except AttributeError:
try:
from importlib import reload
except ImportError:
from imp import reload
# Import salt libs
from salt.utils.timeout import wait_for
@ -132,22 +141,7 @@ 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
try:
reload(vboxapi)
except NameError:
try:
from importlib import reload
reload(vboxapi)
except ImportError:
from imp import reload
reload(vboxapi)
reload(vboxapi)
_virtualboxManager = vboxapi.VirtualBoxManager(None, None)
return _virtualboxManager