Ejemplo n.º 1
0
def record(student, *, specs, to_record, basedir, debug, interact):
    recordings = []
    if not to_record:
        return recordings

    with chdir(student):
        for one_to_record in to_record:
            logging.debug("Recording  {}'s {}".format(student, one_to_record))
            if path.exists(one_to_record):
                with chdir(one_to_record):
                    recording = markdownify(one_to_record,
                                            username=student,
                                            spec=specs[one_to_record],
                                            basedir=basedir,
                                            debug=debug,
                                            interact=interact,
                                            student=student)
            else:
                recording = {
                    'spec': one_to_record,
                    'student': student,
                    'first_submit': "",
                    'warnings': {
                        'no submission': True
                    },
                }

            recordings.append(recording)

    return recordings
Ejemplo n.º 2
0
def record(student, *, specs, to_record, basedir, debug, interact, ci, skip_web_compile):
    recordings = []
    if not to_record:
        return recordings

    directory = student if not ci else '.'
    with chdir(directory):
        for one_to_record in to_record:
            logging.debug("Recording  {}'s {}".format(student, one_to_record))
            if path.exists(one_to_record):
                with chdir(one_to_record):
                    recording = markdownify(one_to_record,
                                            username=student,
                                            spec=specs[one_to_record],
                                            basedir=basedir,
                                            debug=debug,
                                            interact=interact,
                                            ci=ci,
                                            skip_web_compile=skip_web_compile)
            else:
                recording = {
                    'spec': one_to_record,
                    'student': student,
                    'first_submit': "",
                    'warnings': {'no submission': True},
                }

            recordings.append(recording)

    return recordings
Ejemplo n.º 3
0
def analyze(student, specs, check_for_branches):
    logging.debug("Analyzing {}'s assignments".format(student))
    unmerged_branches = has_unmerged_branches(student, check_for_branches)

    results = {}
    with chdir(student):
        for spec in specs.values():
            assignment = spec['assignment']
            results[assignment] = analyze_assignment(spec, assignment)

    homework_list = [
        result for result in results.values() if result['kind'] == 'homework'
    ]
    lab_list = [
        result for result in results.values() if result['kind'] == 'lab'
    ]
    worksheet_list = [
        result for result in results.values() if result['kind'] == 'worksheet'
    ]

    return {
        'username': student,
        'unmerged_branches': unmerged_branches,
        'homeworks': homework_list,
        'labs': lab_list,
        'worksheets': worksheet_list,
    }
Ejemplo n.º 4
0
def analyze_assignment(spec, assignment):
    folder = spec.get('folder', assignment)
    kind, num = parse_assignment_name(assignment)
    results = {'number': num, 'kind': kind}

    if not os.path.exists(folder):
        results['status'] = 'missing'
        return results

    with chdir(folder):
        files_that_do_exist = set(os.listdir('.'))
        files_which_should_exist = set(get_filenames(spec))
        intersection_of = files_that_do_exist.intersection(
            files_which_should_exist)

        if intersection_of == files_which_should_exist:
            # if every file that should exist, does: we're good.
            results['status'] = 'success'
        elif intersection_of:
            # if some files that should exist, do: it's a partial assignment
            results['status'] = 'partial'
        else:
            # otherwise, none of the required files are there
            results['status'] = 'missing'

    return results
Ejemplo n.º 5
0
def analyze_assignment(spec, assignment):
    folder = spec.get('folder', assignment)
    kind, num = parse_assignment_name(assignment)
    results = {'number': num, 'kind': kind}

    if not os.path.exists(folder):
        results['status'] = 'missing'
        return results

    with chdir(folder):
        files_that_do_exist = set(os.listdir('.'))
        files_which_should_exist = set(get_filenames(spec))
        intersection_of = files_that_do_exist.intersection(files_which_should_exist)

        if intersection_of == files_which_should_exist:
            # if every file that should exist, does: we're good.
            results['status'] = 'success'
        elif intersection_of:
            # if some files that should exist, do: it's a partial assignment
            results['status'] = 'partial'
        else:
            # otherwise, none of the required files are there
            results['status'] = 'missing'

    return results
Ejemplo n.º 6
0
def analyze(student, specs, check_for_branches, ci):
    logging.debug("Analyzing {}'s assignments".format(student))
    unmerged_branches = None
    if not ci:
        unmerged_branches = has_unmerged_branches(student, check_for_branches)

    results = {}
    directory = student if not ci else '.'
    with chdir(directory):
        for spec in specs.values():
            assignment = spec['assignment']
            results[assignment] = analyze_assignment(spec, assignment)

    homework_list = [result for result in results.values() if result['kind'] == 'homework']
    lab_list = [result for result in results.values() if result['kind'] == 'lab']
    worksheet_list = [result for result in results.values() if result['kind'] == 'worksheet']

    return {
        'username': student,
        'unmerged_branches': unmerged_branches,
        'homeworks': homework_list,
        'labs': lab_list,
        'worksheets': worksheet_list,
    }
Ejemplo n.º 7
0
def stash(student, no_update):
    logging.debug("Stashing {}'s repository".format(student))
    with chdir(student):
        if not no_update and has_changed_files():
            run(['git', 'stash', '-u'])
            run(['git', 'stash', 'clear'])
Ejemplo n.º 8
0
def pull(student, no_update):
    logging.debug("Pulling {}'s repository".format(student))
    with chdir(student):
        if not no_update:
            run(['git', 'pull', '--quiet', 'origin', 'master'])
Ejemplo n.º 9
0
def has_unmerged_branches(student, should_check):
    with chdir(student):
        if should_check:
            return find_unmerged_branches_in_cwd()
        return None
Ejemplo n.º 10
0
def reset(student):
    with chdir(student):
        run(['git', 'checkout', 'master', '--quiet', '--force'])
Ejemplo n.º 11
0
def has_unmerged_branches(student, should_check):
    with chdir(student):
        if should_check:
            return find_unmerged_branches_in_cwd()
        return None
Ejemplo n.º 12
0
def checkout_date(student, date=None):
    if date:
        logging.debug("Checking out commits in {}'s repository before {}".format(student, date))
        with chdir(student):
            _, rev, _ = run(['git', 'rev-list', '-n', '1', '--before="{} 18:00"'.format(date), 'master'])
            run(['git', 'checkout', rev, '--force', '--quiet'])
Ejemplo n.º 13
0
def checkout_ref(student, ref):
    with chdir(student):
        run(['git', 'checkout', ref, '--force', '--quiet'])