# Path: vmchecker/update_db.py
# def compute_late_penalty(assignment, account, vmcfg):
# def compute_TA_penalty(grade_filename):
# def compute_grade(assignment, user, grade_filename, vmcfg):
# def db_save_grade(vmcfg, assignment, account, submission_root,
#                   course_db, ignore_timestamp = False):
# def update_grades(course_id, account = None, assignment = None,
#         ignore_timestamp = False, simulate = False):


import os
import ldap
import time
import paramiko
import traceback
import codecs
import subprocess
    import simplejson as json
    import json
import gettext
import re
from cgi import escape
from vmchecker import paths, update_db, penalty, submissions, submit, coursedb
from vmchecker.coursedb import opening_course_db
from vmchecker.courselist import CourseList
from vmchecker.config import LdapConfig, StorerCourseConfig
        con.simple_bind_s(user_dn, password)
    except ldap.INVALID_CREDENTIALS:
        return None
    except:
        raise

    return entry['cn'][0]


def _find_file(searched_file_name, rfiles):
    """Search for a filename in an array for {fname:fcontent} dicts"""
    for rfile in rfiles:
        if rfile.has_key(searched_file_name):
            return rfile
    return None



def submission_upload_info(vmcfg, courseId, assignment, account, isTeamAccount, isGraded):
    """Return a string explaining the submission upload time, deadline
    and the late submission penalty
    """

    vmpaths = paths.VmcheckerPaths(vmcfg.root_path())
    sbroot = vmpaths.dir_cur_submission_root(assignment, account)
    grade_file = paths.submission_results_grade(sbroot)
    sbcfg = paths.submission_config_file(sbroot)
    if not os.path.exists(sbcfg):
        return _("No submission exists for this assignment")


# Path: vmchecker/update_db.py
# def compute_late_penalty(assignment, account, vmcfg):
# def compute_TA_penalty(grade_filename):
# def compute_grade(assignment, user, grade_filename, vmcfg):
# def db_save_grade(vmcfg, assignment, account, submission_root,
#                   course_db, ignore_timestamp = False):
# def update_grades(course_id, account = None, assignment = None,
#         ignore_timestamp = False, simulate = False):


# Path: vmchecker/websutil.py
import os
import ldap
import time
import paramiko
import traceback
import codecs
import subprocess
    import simplejson as json
    import json
import gettext
import re
from cgi import escape
from vmchecker import paths, update_db, penalty, submissions, submit, coursedb
from vmchecker.coursedb import opening_course_db
from vmchecker.courselist import CourseList
from vmchecker.config import LdapConfig, StorerCourseConfig

        con.simple_bind_s(user_dn, password)
    except ldap.INVALID_CREDENTIALS:
        return None
    except:
        raise

    return entry['cn'][0]


def _find_file(searched_file_name, rfiles):
    """Search for a filename in an array for {fname:fcontent} dicts"""
    for rfile in rfiles:
        if rfile.has_key(searched_file_name):
            return rfile
    return None



def submission_upload_info(vmcfg, courseId, assignment, account, isTeamAccount, isGraded):
    """Return a string explaining the submission upload time, deadline
    and the late submission penalty
    """

    vmpaths = paths.VmcheckerPaths(vmcfg.root_path())
    sbroot = vmpaths.dir_cur_submission_root(assignment, account)
    grade_file = paths.submission_results_grade(sbroot)
    sbcfg = paths.submission_config_file(sbroot)
    if not os.path.exists(sbcfg):
        return _("No submission exists for this assignment")


    late_penalty = update_db.compute_late_penalty(assignment, account, vmcfg)