Ejemplo n.º 1
0
    def check_log(self, log_type, message):
        log_file_path = os.path.join(self.tmp_dir, LOG_FILES_PATH)

        init_logger()
        debug_level = 'debug'
        if log_type.lower() == debug_level:
            set_level(debug_level)

        self.logs[log_type](message)
        out, err = self.capfd.readouterr()

        if log_type == 'ERROR':
            file_location = output_messages['ERROR_FIND_FILE_PATH_LOCATION'] % LOG_FILE_NAME
            self.assertIn(file_location, out)

        self.assertIn(message, err)
        self.assertTrue(os.path.exists(log_file_path))

        log_file = os.path.join(log_file_path, LOG_FILE_NAME)
        self.assertTrue(os.path.exists(log_file))
        with open(log_file, 'r') as lf:
            self.assertIn(message, lf.read())
Ejemplo n.º 2
0
def run_main():
    try:
        init_logger()
        general.mlgit()
    except Exception as e:
        click.secho(str(e), fg='red')
Ejemplo n.º 3
0
"""
© Copyright 2020 HP Development Company, L.P.
SPDX-License-Identifier: GPL-2.0-only
"""

import os
import shutil
import tempfile

from ml_git import log
from ml_git.config import config_load
from ml_git.repository import Repository
from ml_git.log import init_logger

init_logger()


def get_repository_instance(repo_type):
    return Repository(config_load(), repo_type)


def validate_sample(sampling):
    if 'group' in sampling or 'random' in sampling:
        if 'seed' not in sampling:
            log.error(
                'It is necessary to pass the attribute \'seed\' in \'sampling\'. Example: {\'group\': \'1:2\', '
                '\'seed\': \'10\'}.')
            return False
    elif 'range' not in sampling:
        log.error(
            'To use the sampling option, you must pass a valid type of sampling (group, '