'Perform the course structure generation workflow'

def handle(self, *args, **options):

    if options['all']:
        course_keys = [course.id for course in modulestore().get_courses()]
    else:
        course_keys = [CourseKey.from_string(arg) for arg in args]
    if (not course_keys):
        log.fatal('No    courses    specified.')
        return
    log.info('Generating    course    structures    for    %d    courses.', len(course_keys))
    log.debug('Generating    course    structure(s)    for    the    following    courses:    %s', course_keys)
    for course_key in course_keys:
        try:
            update_course_structure.apply(args=[unicode(course_key)])
        except Exception as ex:
            log.exception('An    error    occurred    while    generating    course    structure    for    %s:    %s', unicode(course_key), ex.message)
    log.info('Finished    generating    course    structures.')
