-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix avocado-vt issue:https://github.com/avocado-framework/avocado-vt/… #3392
Fix avocado-vt issue:https://github.com/avocado-framework/avocado-vt/… #3392
Conversation
Error running method "initialize" of plugin "vt-init": cannot import name 'log_line' when import from virttest import utils_misc in python terminal virttest/utils_logfile.py and virttest/utils_misc.py duplicate the same code : def log_line(filename, line) implementation need change virttest/ip_sniffing.py to import log_line from virttest/utils_logfile.py Signed-off-by: chunfuwen <[email protected]>
Fix the issue:#3391 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, the manual test fails still for me, s. run below. I do not know which magic importlib does. Would it be safer to rename one of both log_line
instances or if they are the same remove one of them?
Reproduced traceback from: /home/smitterl/NotBackedUp/avocado-tmp/avocado/avocado/core/extension_manager.py:216
Traceback (most recent call last):
File "/home/smitterl/NotBackedUp/avocado-tmp/avocado-vt/avocado_vt/plugins/vt_init.py", line 276, in initialize
virt_loader = getattr(importlib.import_module('avocado_vt.loader'),
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/smitterl/NotBackedUp/avocado-tmp/avocado-vt/avocado_vt/loader.py", line 33, in <module>
from .test import VirtTest
File "/home/smitterl/NotBackedUp/avocado-tmp/avocado-vt/avocado_vt/test.py", line 33, in <module>
from virttest import utils_env
File "/home/smitterl/NotBackedUp/avocado-tmp/avocado-vt/virttest/utils_env.py", line 19, in <module>
from virttest import ip_sniffing
File "/home/smitterl/NotBackedUp/avocado-tmp/avocado-vt/virttest/ip_sniffing.py", line 21, in <module>
from virttest.utils_logfile import log_line
ImportError: cannot import name 'log_line'
Error running method "initialize" of plugin "vt-init": cannot import name 'log_line'
I compared both functions https://github.com/avocado-framework/avocado-vt/blob/master/virttest/utils_logfile.py#L45 https://github.com/avocado-framework/avocado-vt/search?q=log_line |
Looks like what happened was that we tried to remove dependency on |
@luckyh - Some code consumed by tp-qemu seems to be consuming the That function was moved to the module |
I just tried to modify the code as the following and seems it could work properly (no ideas about how diff --git a/virttest/ip_sniffing.py b/virttest/ip_sniffing.py
index 5c711f21..acddf291 100644
--- a/virttest/ip_sniffing.py
+++ b/virttest/ip_sniffing.py
@@ -18,7 +18,7 @@ from avocado.utils import process
import six
-from virttest.utils_misc import log_line
+from virttest import utils_misc
from virttest.utils_version import VersionInterval
LOG = logging.getLogger('avocado.' + __name__)
@@ -174,7 +174,7 @@ class Sniffer(object):
def _output_logger_handler(self, line):
try:
- log_line(self._logfile, line)
+ utils_misc.log_line(self._logfile, line)
except Exception as e:
LOG.warn("Can't log ip sniffer output: '%s'", e)
if self._output_handler(line): and the interesting thing is that I supposed it should work as well with using the one provided by
@smitterl so my concern is we need to ensure that Thanks, |
Oops, just close this by mistaken, sorry for the inconvenience. |
Close it firstly, since there is no further feedbacks |
…issues/3391
Error running method "initialize" of plugin "vt-init": cannot import name 'log_line' when
import from virttest import utils_misc in python terminal
virttest/utils_logfile.py and virttest/utils_misc.py duplicate the same code :
def log_line(filename, line) implementation
need change virttest/ip_sniffing.py to import log_line from virttest/utils_logfile.py
Signed-off-by: chunfuwen [email protected]