<commit_before>"""
Orchestrates the launch process by wrapping a launch plugin
"""

__license__ = """
This file is part of RAPD

Copyright (C) 2009-2017, Cornell University
All rights reserved.

RAPD is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3.

RAPD is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
__created__ = "2009-07-10"
__maintainer__ = "<NAME>"
__email__ = "<EMAIL>"
__status__ = "Production"

# Standard imports
import argparse
import importlib
import json
import os
import sys

# RAPD imports
import utils.commandline
import utils.log
from utils.modules import load_module
import utils.site

class Launch(object):
    """
    Launches json-formatted RAPD command files using the command-appropriate
    rapd plugin
    """

    command = None
    plugin = None
    logger = None

    def __init__(self, site, command_file):
        """
        Initialize the Launch
        """

        # Save passed-in variables
        self.site = site
        self.command_file = command_file

        self.run()

    def run(self):
        """
        Orchsetrate the Launch process
        """

        # Start the logger
        self.init_logger()

        # Load and decode json command file
        self.command = self.load_command()

        # Put the site object into the command
        self.command["site"] = self.site

        self.logger.debug("command: %s", self.command.get("command", None))

        # Load the plugin for this command
        self.load_plugin(self.command.get("command"))

        # Run the plugin
        self.plugin.RapdPlugin(command=self.command,
                               tprint=False,
                               logger=self.logger)

    def load_command(self):
        """
        Load and parse the command file
        """

        # Load the file
        message = open(self.command_file, "r").read()

        # Decode json command file
        return json.loads(message)

    def load_plugin(self, command):<commit_msg>Change launch to work with 2-step, instantiate and then run plugin<commit_after>"""
Orchestrates the launch process by wrapping a launch plugin
"""

__license__ = """
This file is part of RAPD

Copyright (C) 2009-2017, Cornell University
All rights reserved.

RAPD is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3.

RAPD is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
__created__ = "2009-07-10"
__maintainer__ = "<NAME>"
__email__ = "<EMAIL>"
__status__ = "Production"

# Standard imports
import argparse
import importlib
import json
import os
import sys

# RAPD imports
import utils.commandline
import utils.log
from utils.modules import load_module
import utils.site

class Launch(object):
    """
    Launches json-formatted RAPD command files using the command-appropriate
    rapd plugin
    """

    command = None
    plugin = None
    logger = None

    def __init__(self, site, command_file):
        """
        Initialize the Launch
        """

        # Save passed-in variables
        self.site = site
        self.command_file = command_file

        self.run()

    def run(self):
        """
        Orchsetrate the Launch process
        """

        # Start the logger
        self.init_logger()

        # Load and decode json command file
        self.command = self.load_command()

        # Put the site object into the command
        self.command["site"] = self.site

        self.logger.debug("command: %s", self.command.get("command", None))

        # Load the plugin for this command
        self.load_plugin(self.command.get("command"))

        # Run the plugin
        plugin = self.plugin.RapdPlugin(command=self.command,
                                        tprint=False,
                                        logger=self.logger)

        plugin.start()

    def load_command(self):
        """
        Load and parse the command file
        """

        # Load the file
        message = open(self.command_file, "r").read()

        # Decode json command file
        return json.loads(message)

    def load_plugin(self, command):
{'fraction_non_alphanumeric': 0.07885159725030327, 'fraction_numerical': 0.007076425394257986, 'mean_word_length': 2.531049250535332, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6115833', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1296, 'n_words': 503}