mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix ansible-test injector warning on Python 3.7.
This commit is contained in:
parent
919e310b99
commit
e12d3ca731
1 changed files with 14 additions and 4 deletions
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
"""Provides an entry point for python scripts and python modules on the controller with the current python interpreter and optional code coverage collection."""
|
||||
|
||||
import imp
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -18,9 +17,20 @@ def main():
|
|||
if coverage_output:
|
||||
args += ['-m', 'coverage.__main__', 'run', '--rcfile', coverage_config]
|
||||
else:
|
||||
try:
|
||||
imp.find_module('coverage')
|
||||
except ImportError:
|
||||
if sys.version_info >= (3, 4):
|
||||
import importlib.util
|
||||
|
||||
found = bool(importlib.util.find_spec('coverage'))
|
||||
else:
|
||||
import imp
|
||||
|
||||
try:
|
||||
imp.find_module('coverage')
|
||||
found = True
|
||||
except ImportError:
|
||||
found = False
|
||||
|
||||
if not found:
|
||||
exit('ERROR: Could not find `coverage` module. Did you use a virtualenv created without --system-site-packages or with the wrong interpreter?')
|
||||
|
||||
if name == 'python.py':
|
||||
|
|
Loading…
Reference in a new issue