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

write interpreter details into bzt.log #1416

Merged
merged 6 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions bzt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ def __init__(self, options):
self.log.debug("Command-line options: %s", self.options)
self.log.debug("Python: %s %s", platform.python_implementation(), platform.python_version())
self.log.debug("OS: %s", platform.uname())

try:
self.log.debug("Path to interpreter: {}".format(sys.executable))
self.log.debug("Path to packages: {}".format(sys.path))
self.log.debug("Default python: {}".format(shutil.which('python' or 'not found')))
self.log.debug("Default python3: {}".format(shutil.which('python3' or 'not found')))

except BaseException as exc:
self.log.warning("Extended python info getting error: {}".format(exc))


self.engine = Engine(self.log)
self.exit_code = 0

Expand Down Expand Up @@ -270,6 +281,14 @@ def perform(self, configs):
except BaseException as exc:
self.handle_exception(exc)

if self.options.verbose:
for module_name in sys.modules:
version = str(getattr(sys.modules[module_name], '__version__', ""))
file = getattr(sys.modules[module_name], '__file__', "")
if version:
module_name = "-".join((module_name, version))
self.log.debug("\t{}\t{}".format(module_name, file))

self.log.info("Artifacts dir: %s", self.engine.artifacts_dir)
if self.engine.artifacts_dir is None:
self.log.info("Log file: %s", self.options.log)
Expand Down
5 changes: 3 additions & 2 deletions bzt/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ def set_pythonpath(self):
self.temp_pythonpath = get_full_path(os.path.join(self.artifacts_dir, path_suffix))
current_pythonpath = os.environ.get('PYTHONPATH', '')
paths = self.user_pythonpath, self.temp_pythonpath, current_pythonpath
self.log.debug("Set PYTHONPATH to '{}' + '{}' + {}".format(*paths))

self.log.debug("Set PYTHONPATH to :\n\tUSER: '{}' +\n\tTEMP: '{}' +\n\tCURRENT: '{}'".format(*paths))
try:
user_packages = os.listdir(self.user_pythonpath)
except:
user_packages = []

self.log.debug("Content of user packages dir: %s".format(user_packages))
self.log.debug("Content of user packages dir: {}".format(user_packages))

os.environ['PYTHONPATH'] = os.pathsep.join(paths)

Expand Down
9 changes: 4 additions & 5 deletions bzt/modules/tsung.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import re
import traceback
from urllib import parse
from shutil import which

from bzt import TaurusConfigError, ToolError, TaurusInternalException
from bzt.engine import FileLister, ScenarioExecutor, HavingInstallableTools, SelfDiagnosable
from bzt.modules.aggregator import ConsolidatingAggregator, ResultsReader
from bzt.modules.console import WidgetProvider, ExecutorWidget
from bzt.requests_model import HTTPRequest
from bzt.utils import etree, iteritems
from bzt.utils import CALL_PROBLEMS, shutdown_process, RequiredTool, dehumanize_time, which, FileReader
from bzt.utils import CALL_PROBLEMS, shutdown_process, RequiredTool, dehumanize_time, FileReader, etree, iteritems


class TsungExecutor(ScenarioExecutor, WidgetProvider, FileLister, HavingInstallableTools, SelfDiagnosable):
Expand Down Expand Up @@ -439,9 +439,8 @@ def get_tool_abspath(self):
if os.path.exists(abspath):
return abspath

executables = which(self.tool_path)
if executables:
return executables[0]
return which(self.tool_path)


@staticmethod
def get_tool_prefix(tool_abspath):
Expand Down
11 changes: 0 additions & 11 deletions bzt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1616,17 +1616,6 @@ def draw_screen(self, size, canvas):
LOG.info("Screen %sx%s chars:\n%s", size[0], size[1], data)


def which(filename):
"""unix-style `which` implementation"""
locations = os.environ.get("PATH").split(os.pathsep)
candidates = []
for location in locations:
candidate = os.path.join(location, filename)
if os.path.isfile(candidate):
candidates.append(candidate)
return candidates


class PythonGenerator(object):
IMPORTS = ''
INDENT_STEP = 4
Expand Down
1 change: 1 addition & 0 deletions site/dat/docs/changes/extend-python-env-log.chage
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
write interpreter and packages details into log