Пример #1
0
def create_tasks_from_config(tasks_config_file):
    ''' Returns a TaskScheduler based on either:

        - a json configuration file.
        - a python module with a function create_tasks that does the job
        of returning the task scheduler.
    '''
    fformat = tasks_config_file.split('.')[-1]
    if fformat == 'json':
        config_loader = JSONConfigLoader()
    elif fformat == 'py':
        config_loader = PythonConfigLoader()
    else:
        raise RuntimeError("Unknown configuration file format '.{fformat}' of"
                           " {filename}".format(fformat=fformat,
                                                filename=tasks_config_file))
    return config_loader.create_tasks(tasks_config_file)
Пример #2
0
def create_tasks_from_config(tasks_config_file):
    """ Returns a TaskScheduler based on either: a json configuration file or a python module with a function
    create_tasks, that does the job of returning the task scheduler.

    :param tasks_config_file:
    :return:
    """
    fformat = tasks_config_file.split('.')[-1]
    if fformat == 'json':
        config_loader = JSONConfigLoader()
    elif fformat == 'py':
        config_loader = PythonConfigLoader()
    else:
        # TODO unreslove ref to fformat
        raise RuntimeError(
                "Unknown configuration file format '.{"
                ""fformat}' of" " {filename}".format(fformat=fformat, filename=tasks_config_file))
    return config_loader.create_tasks(tasks_config_file)