Exemplo n.º 1
0
def main():
    """Checks for modified grades and updates the database"""
    config.config_storer()

    db_conn = sqlite3.connect(vmcheckerpaths.db_file(),
                              isolation_level="EXCLUSIVE")
    db_cursor = db_conn.cursor()

    def _update_grades_wrapper(assignment, user, location, db_cursor):
        """A wrapper over _update_grades to use with repo_walker"""
        assignment_id = _db_get_assignment_id(db_cursor, assignment)
        user_id = _db_get_user_id(db_cursor, user)

        grade_filename = os.path.join(location, vmcheckerpaths.GRADE_FILENAME)
        if os.path.exists(grade_filename):
            _update_grades(assignment_id, user_id, grade_filename, db_cursor)
            _logger.info('Updated %s, %s (%s)', assignment, user, location)
        else:
            _logger.error('No results found for %s, %s (check %s)',
                          assignment, user, grade_filename)

    repo_walker.walk(_update_grades_wrapper, args=(db_cursor,))

    db_cursor.close()
    db_conn.commit()
    db_conn.close()
Exemplo n.º 2
0
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""An useful script for mass homeworks resubmition"""


import config
import submit
import repo_walker


def _submit(assignment, user, location):
    """Submits assignment from `location'"""
    submit.submit_homework(location)


if __name__ == '__main__':
    config.config_storer()
    repo_walker.walk(_submit)