<commit_before># -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


import os, subprocess

DEPLOYMENT_STEPS_HOME = os.path.realpath(os.path.join(os.path.dirname(__file__), '../steps'))


class ScenarioRunner(object):

    def run_step(self, step_name, host_config_specification):
        exit_code = self._run_script(os.path.join(DEPLOYMENT_STEPS_HOME, step_name + '.py'), host_config_specification)

        self._stop_scenario_execution_if_deployment_step_failed(exit_code)

    def _run_script(self, script_path, host_config_specification):
        return subprocess.call([script_path, host_config_specification])

    def _stop_scenario_execution_if_deployment_step_failed(self, exit_code):
        # we should already see a failure message when a deployment fails
        if exit_code != 0:
            raise SystemExit
<commit_msg>[#23361761] Updated the ScenarioRunner so that we can run data retrieval and other tasks that don't require an explicit host config specification (where this will be specified elsewhere).<commit_after># -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.


import os, subprocess

DEPLOYMENT_STEPS_HOME = os.path.realpath(os.path.join(os.path.dirname(__file__), '../steps'))


class ScenarioRunner(object):

    def run_step(self, step_name, host_config_specification=None):
        exit_code = self._run_script(os.path.join(DEPLOYMENT_STEPS_HOME, step_name + '.py'), host_config_specification)

        self._stop_scenario_execution_if_deployment_step_failed(exit_code)

    def _run_script(self, script_path, host_config_specification):
        if host_config_specification:
            return subprocess.call([script_path, host_config_specification])
        else:
            return subprocess.call(script_path)

    def _stop_scenario_execution_if_deployment_step_failed(self, exit_code):
        # we should already see a failure message when a deployment fails
        if exit_code != 0:
            raise SystemExit

{'fraction_non_alphanumeric': 0.08233347124534547, 'fraction_numerical': 0.004964832436905255, 'mean_word_length': 4.13375796178344, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '127853', 'n_tokens_mistral': 740, 'n_tokens_neox': 705, 'n_words': 202}