'Generates course blocks for the given course_key per the given options.'

def _generate_for_course(self, options, course_key):

    if options.get('enqueue_task'):
        action = (tasks.update_course_in_cache_v2 if options.get('force_update') else tasks.get_course_in_cache_v2)
        task_options = ({'routing_key': options['routing_key']} if options.get('routing_key') else {})
        result = action.apply_async(kwargs=dict(course_id=unicode(course_key), with_storage=options.get('with_storage')), **task_options)
        log.info(u'BlockStructure:    ENQUEUED    generating    for    course:    %s,    task_id:    %s.', course_key, result.id)
    else:
        log.info(u'BlockStructure:    STARTED    generating    for    course:    %s.', course_key)
        action = (api.update_course_in_cache if options.get('force_update') else api.get_course_in_cache)
        action(course_key)
        log.info(u'BlockStructure:    FINISHED    generating    for    course:    %s.', course_key)
