Skip to content
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

vt_init raises errors when importing avocado-vt modules into python session #3391

Open
smitterl opened this issue Apr 6, 2022 · 2 comments

Comments

@smitterl
Copy link
Contributor

smitterl commented Apr 6, 2022

With the latest master today (avocado 94.0) there are errors when loading avocado-vt modules into python3 session.
I tried using avocado 92lts and 82lts but this issue reproduces.
After the error message, the module is available and I confirmed the log_line function that can't be imported is available in the utils_misc. I'm not familiar with the importlib, any idea how to debug this?

$ python3 --version
Python 3.6.8
$ cd avocado
$ pip install -r requirements-dev.txt
$ pip install -e .
$ cd ../avocado-vt
$ pip install -r 
$ pip install -r requirements.txt
$ pip install -e .
$ python3
>> from virttest import utils_misc
No python imaging library installed. Screendump and Windows guest BSOD detection are disabled. In order to enable it, please install python-imaging or the equivalent for your distro.
No python imaging library installed. PPM image conversion to JPEG disabled. In order to enable it, please install python-imaging or the equivalent for your distro.

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_misc import log_line
ImportError: cannot import name 'log_line'

Error running method "initialize" of plugin "vt-init": cannot import name 'log_line'
>>>
@smitterl smitterl changed the title Can't load avocado-vt modules into python console because vt_init fails vt_init raises errors when importing avocado-vt modules into python session Apr 6, 2022
@chunfuwen
Copy link
Contributor

virttest/utils_logfile.py and virttest/utils_misc.py duplicate the same code : def log_line(filename, line) implementation. I try import log_line from virttest/utils_logfile.py in the file virttest/ip_sniffing.py, the issue can be fixed

chunfuwen added a commit to chunfuwen/avocado-vt that referenced this issue Apr 6, 2022
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]>
@chunfuwen
Copy link
Contributor

#3392

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants