Skip to content

Commit

Permalink
Refactor even further
Browse files Browse the repository at this point in the history
  • Loading branch information
dimp-gh committed Apr 1, 2016
1 parent 4eaaf32 commit fcab09b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
5 changes: 3 additions & 2 deletions bzt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def perform(self, configs):
if self.options.no_system_configs is None:
self.options.no_system_configs = False

self.engine.configure(configs, not self.options.no_system_configs)
merged_config = self.engine.configure(configs, not self.options.no_system_configs)

# apply aliases
for alias in self.options.aliases:
Expand All @@ -150,7 +150,8 @@ def perform(self, configs):
overrider = ConfigOverrider(self.log)
overrider.apply_overrides(self.options.option, self.engine.config)

self.engine.create_artifacts_dir(configs)
self.engine.create_artifacts_dir(configs, merged_config)

self.engine.prepare()
self.engine.run()
exit_code = 0
Expand Down
16 changes: 7 additions & 9 deletions bzt/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def __init__(self, parent_logger):
self.log = parent_logger.getChild(self.__class__.__name__)
self.config = Configuration()
self.config.log = self.log.getChild(Configuration.__name__)
self.merged_config = None
self.modules = {} # available modules
self.provisioning = Provisioning()
self.aggregator = EngineModule() # FIXME: have issues with non-aggregator object set here
Expand All @@ -88,13 +87,15 @@ def configure(self, user_configs, read_config_files=True):
if read_config_files:
self._load_base_configs()

self.merged_config = self._load_user_configs(user_configs)
merged_config = self._load_user_configs(user_configs)

self._load_included_configs()
self.config.merge({"version": bzt.VERSION})
self._set_up_proxy()
self._check_updates()

return merged_config

def prepare(self):
"""
Prepare engine for work, will create artifacts dir, call preparing of Provisioning
Expand Down Expand Up @@ -283,13 +284,10 @@ def existing_artifact(self, filename, move=False):
self.log.debug("Copying %s to %s", filename, newname)
shutil.copy(filename, newname)

def create_artifacts_dir(self, existing_artifacts=None):
def create_artifacts_dir(self, existing_artifacts=(), merged_config=None):
"""
Create directory for artifacts, directory name based on datetime.now()
"""
if existing_artifacts is None:
existing_artifacts = []

if self.artifacts_dir:
self.artifacts_dir = os.path.expanduser(self.artifacts_dir)
else:
Expand All @@ -310,9 +308,9 @@ def create_artifacts_dir(self, existing_artifacts=None):
self.config.dump()

# dump merged configuration
if self.merged_config:
self.merged_config.dump(self.create_artifact("merged", ".yml"), Configuration.YAML)
self.merged_config.dump(self.create_artifact("merged", ".json"), Configuration.JSON)
if merged_config:
merged_config.dump(self.create_artifact("merged", ".yml"), Configuration.YAML)
merged_config.dump(self.create_artifact("merged", ".json"), Configuration.JSON)

for artifact in existing_artifacts:
self.existing_artifact(artifact)
Expand Down

0 comments on commit fcab09b

Please sign in to comment.