コード例 #1
0
def main_storer():
    """Run initialization tasks for the storer machine."""
    config.config_storer()
    create_storer_paths()
    create_storer_git_repo()
    create_db()
    _logger.info(' -- storer init done setting up paths and db file.')
コード例 #2
0
ファイル: update_db.py プロジェクト: MihaiTabara/vmchecker
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()
コード例 #3
0
ファイル: submit.py プロジェクト: ironmissy/vmchecker
def main():
    """Parse arguments and submits the homework"""

    config.cmdline.set_usage("Usage: %prog [options] assignment user archive")
    config.config_storer()

    if len(config.argv) != 3:
        config.cmdline.error("Not enough arguments")

    assignment = config.argv[0]
    user = config.argv[1]
    archive = config.argv[2]

    if not os.path.isfile(archive):
        config.cmdline.error("%s must be an existing file." % archive)
    if assignment not in config.assignments:
        config.cmdline.error("%s must be a valid assignment." % assignment)

    # checks time difference
    if not config.options.force:
        upload_time = submissions.get_upload_time(assignment, user)

        if upload_time is not None:
            remaining = upload_time
            remaining += config.assignments.timedelta(assignment)
            remaining -= datetime.datetime.now()

            if remaining > datetime.timedelta():
                _logger.fatal("You are submitting too fast")
                _logger.fatal("Please allow %s between submissions", str(config.assignments.timedelta(assignment)))
                _logger.fatal("Try again in %s", remaining)
                exit(1)

    location = build_config(assignment, user, archive)
    submit_homework(location)
コード例 #4
0
ファイル: view_grades.py プロジェクト: MihaiTabara/vmchecker
def main():
    config.config_storer()

    global db_cursor
    db_conn = sqlite3.connect(vmcheckerpaths.db_file())
    db_cursor = db_conn.cursor()

    (results, hws) = get_db_content()
    # send to the stdout all the HTML content
    print gen_html(results, hws)
    db_cursor.close()
    db_conn.close()

    print """
コード例 #5
0
ファイル: view_grades.py プロジェクト: ironmissy/vmchecker
def main():
    """Reads grades and generates the HTML table"""
    config.config_storer()

    db_conn = sqlite3.connect(vmcheckerpaths.db_file())
    db_cursor = db_conn.cursor()

    results = _db_retrieve_grades(db_cursor)
    assignments = sorted(config.assignments)

    # sends to the stdout all the HTML content
    print _generate_html(results, assignments)
    print _powered_by_vmchecker()

    db_cursor.close()
    db_conn.close()
コード例 #6
0
def create_storer_paths():
    """Create all paths used by vmchecker on the storer machine"""
    config.config_storer()
    _create_paths(vmcheckerpaths.storer_paths())
コード例 #7
0
ファイル: submit.py プロジェクト: MihaiTabara/vmchecker
    elif len(sys.argv) == 2:
        if not isfile(sys.argv[1]):
            print >> sys.stderr, '`%s\' must be an existing file.' % sys.argv[1]
            print_help()
            exit(1)

        assignment_config = sys.argv[1]
    elif len(sys.argv) == 4:
        if not isfile(sys.argv[3]):
            print >> sys.stderr, '`%s\' must be an existing file.' % sys.argv[3]
            print_help()
            exit(1)

        user = sys.argv[1]           # student's name
        assignment = sys.argv[2]     # assignment
        archive = sys.argv[3]        # archive
        assignment_config = build_config(user, assignment, archive)
    else:
        print_help()
        exit(1)

    print >> sys.stderr, 'Assignment config located at `%s\'' % assignment_config
    submit_assignment(assignment_config)


if __name__ == '__main__':
    config.config_storer()
    logging.basicConfig(level=logging.DEBUG)
    main()