make reading test environment config automatically create Environment objects

This work is done as a part of preparing the code base to make it reusable in
the planned tools/run_all_tests.cmd Python port as there exactly the same
Environment objects will need to be created.
This commit is contained in:
Jurko Gospodnetić 2014-05-28 19:51:06 +02:00
parent 81af9cc694
commit c83ed42aa9
2 changed files with 13 additions and 14 deletions

View File

@ -280,9 +280,9 @@ class ScanProgressReporter:
"""
def __init__(self, environment_names):
self.__max_name_length = max(len(x) for x in environment_names)
self.__count = len(environment_names)
def __init__(self, environments):
self.__max_name_length = max(len(x.name()) for x in environments)
self.__count = len(environments)
self.__count_width = len(str(self.__count))
self.__current = 0
self.__reporting = False
@ -329,16 +329,14 @@ class ScannedEnvironmentTracker:
self.__last_name = name
def scan_python_environment(name, progress_reporter, environment_tracker):
environment_tracker.track_name(name)
env = None
def scan_python_environment(env, progress_reporter, environment_tracker):
environment_tracker.track_name(env.name())
# N.B. No custom output allowed between calls to our progress_reporter's
# report_start() & report_finish() methods or we risk messing up its output
# formatting.
progress_reporter.report_start(name)
progress_reporter.report_start(env.name())
try:
try:
env = Environment(name)
out, err, exit_code = env.run_initial_scan()
except:
progress_reporter.report_finish("----- %s" % (_exc_str(),))
@ -355,13 +353,13 @@ def scan_python_environment(name, progress_reporter, environment_tracker):
def scan_python_environments():
environment_names = config.python_environments
if not environment_names:
environments = config.python_environments
if not environments:
raise BadConfiguration("No Python environments configured.")
progress_reporter = ScanProgressReporter(environment_names)
progress_reporter = ScanProgressReporter(environments)
environment_tracker = ScannedEnvironmentTracker()
for name in environment_names:
scan_python_environment(name, progress_reporter, environment_tracker)
for env in environments:
scan_python_environment(env, progress_reporter, environment_tracker)
return environment_tracker.environments()

View File

@ -32,6 +32,7 @@ if sys.version_info < (3,):
else:
import configparser
from suds_devel.environment import Environment
import suds_devel.utility as utility
@ -101,7 +102,7 @@ class Config(object):
raise BadConfiguration("'%s.%s' environment command "
"configuration option must not be empty." % (section,
command_option))
self.python_environments.append(command)
self.python_environments.append(Environment(command))
def __init_ini_file(self, ini_file):
self.ini_file = os.path.join(self.project_folder, ini_file)