コード例 #1
0
def update_values(config):
    # override defaults values with program options
    values = merge(config['options'], config['defaults'])

    # set defaults if missing
    if not values.get('work_dir'):
        values['work_dir'] = tempfile.gettempdir()

    config['values'] = values
コード例 #2
0
def get_courses_with_env(config):
    courses_with_env = {}
    courses = config['values']['course']

    for environment in config['environments']:
         kwargs = merge(config['values'], config['environments'][environment])
         all_courses  = get_all_courses(**kwargs)

         if all_courses:
             found_courses = set(courses) & set(all_courses)
             courses_with_env.update({course: environment for course in found_courses})
             courses = set(courses) - found_courses

    if courses:
        log.error("Failed to find courses: %s", list(courses))
        raise FatalTaskError("Failed to find courses in configured environments.")

    return courses_with_env
コード例 #3
0
def get_config_for_course(config, course):
    # config['values'] are overridden default values with program options, every other key is from the config file.
    course_config = merge(config['values'], {'tasks': config['tasks']})
    course_config['course'] = course
    course_config['environments'] = config['environments']
    return course_config
コード例 #4
0
def get_config_for_env(config, environment):
    env_config = merge(config, config['environments'][environment])
    env_config['environment'] = environment
    return env_config
コード例 #5
0
def get_config_for_org(config, organization):
    org_config = merge(config['organizations'][organization], config['values'])
    org_config['organization'] = organization
    org_config['environments'] = config['environments']
    return org_config