Exemple #1
0
    def setUp(self):
        self.plugin_path = os.path.dirname(tasks.__file__)
        self._mock_batch_run = None
        self.batch_folder = os.path.expandvars("$TEMP/jeanpaulstart")
        self.yaml_filepath = os.path.expandvars(
            "$TEMP/jeanpaulstart/batch1.yml").replace('\\', '/')
        self.json_filepath = os.path.expandvars(
            "$TEMP/jeanpaulstart/batch2.json").replace('\\', '/')
        self.tags_filepath = os.path.expandvars(
            "$TEMP/jeanpaulstart/tags.yml").replace('\\', '/')

        if os.path.isfile(self.yaml_filepath):
            os.remove(self.yaml_filepath)

        if os.path.isfile(self.json_filepath):
            os.remove(self.json_filepath)

        if os.path.isfile(self.tags_filepath):
            os.remove(self.tags_filepath)

        if os.path.isdir(self.batch_folder):
            os.rmdir(self.batch_folder)

        os.makedirs(self.batch_folder)

        with open(self.yaml_filepath, "w+") as f_yaml:
            f_yaml.write(BATCH_YAML_CONTENT)

        with open(self.json_filepath, "w+") as f_json:
            f_json.write(BATCH_JSON_CONTENT)

        with open(self.tags_filepath, "w+") as f_tags:
            f_tags.write(TAGS_FILE_CONTENT)

        plugin_loader.init(force=True)
Exemple #2
0
    def tearDown(self):
        if os.path.isfile(self.yaml_filepath):
            os.remove(self.yaml_filepath)

        if os.path.isfile(self.json_filepath):
            os.remove(self.json_filepath)

        if os.path.isfile(self.tags_filepath):
            os.remove(self.tags_filepath)

        if os.path.isdir(self.batch_folder):
            os.rmdir(self.batch_folder)

        plugin_loader.init(plugin_folder="impossible/folder", force=True)
    def test_init(self):
        has_loaded = plugin_loader.init(self.plugin_folder, force=True)
        self.assertEqual(len(plugin_loader.loaded_plugins), 1)

        self.assertEqual(plugin_loader.loaded_plugins.keys(), ['command-name'])

        self.assertTrue(has_loaded)
Exemple #4
0
import copy
from jeanpaulstart import plugin_loader
from jeanpaulstart.constants import *


plugin_loader.init()


def _ignore_errors(task_dict):
    return task_dict.get('ignore_errors', False)


def _register_status(task_dict):
    return task_dict.get('register_status', False)


def _split_keys_and_deep_copy(task):
    command_name = task.keys()[1]

    splitted = {
        'name': task['name'],
        'command': command_name,
        'arguments': task[command_name],
        'ignore_errors': _ignore_errors(task),
        'register_status': _register_status(task)
    }

    return copy.deepcopy(splitted)


def _make_task_from_environment(name, value):
    def test_init_twice_with_force(self):
        plugin_loader.init(self.plugin_folder)
        has_loaded = plugin_loader.init(self.plugin_folder, force=True)

        self.assertTrue(has_loaded)
    def test_init_twice(self):
        plugin_loader.init(self.plugin_folder)
        has_loaded = plugin_loader.init(self.plugin_folder)

        self.assertFalse(has_loaded)
Exemple #7
0
def load_plugins():
    """
    Initialize the plugin loader
    """
    plugin_loader.init(force=True)