Exemplo n.º 1
0
def from_config(config_path):
    """Load all require components from configuration file

    :param str config_path: the path to json configuration file
    :return: module file and loaded configuration
    """
    config = validate_conf(config_path)
    cfg_path = os.path.dirname(config_path)
    module_file = os.path.join(cfg_path, config['script'])
    module = load_file(module_file)
    return module, config
Exemplo n.º 2
0
def from_config(config_path):
    """Load all require components from configuration file

    :param str config_path: the path to json configuration file
    :return: module file and loaded configuration
    """
    config = validate_conf(config_path)
    cfg_path = os.path.dirname(config_path)
    module_file = os.path.join(cfg_path, config['script'])
    module = load_file(module_file)
    return module, config
Exemplo n.º 3
0
def from_tar(tar_path, unique_id, dir_name):
    """Load all require components from tar archive

    :param str tar_path: the path to json configuration file
    :param str unique_id: the unique identifier of the turret
    :param str dir_name: the full path for extraction
    :return: module file and loaded configuration
    """

    if not unpack(tar_path, dir_name):
        raise InvalidTarTurret("Invalide tar file provided")

    try:
        config = validate_conf(os.path.join(dir_name, 'config.json'))
    except InvalidConfiguration:
        clean_tar_tmp(dir_name, True)
        raise

    module_file = os.path.join(dir_name, config['script'])
    module = load_file(module_file)
    return module, config
Exemplo n.º 4
0
def from_tar(tar_path, unique_id, dir_name):
    """Load all require components from tar archive

    :param str tar_path: the path to json configuration file
    :param str unique_id: the unique identifier of the turret
    :param str dir_name: the full path for extraction
    :return: module file and loaded configuration
    """

    if not unpack(tar_path, dir_name):
        raise InvalidTarTurret("Invalide tar file provided")

    try:
        config = validate_conf(os.path.join(dir_name, 'config.json'))
    except InvalidConfiguration:
        clean_tar_tmp(dir_name, True)
        raise

    module_file = os.path.join(dir_name, config['script'])
    module = load_file(module_file)
    return module, config