Example #1
0
def beginEvaluation(req, courseId, assignmentId, archiveFileName):
    """ Saves a temp file of the uploaded archive and calls
        vmchecker.submit.submit method to put the homework in
        the testing queue"""

    # Check permission
    req.content_type = 'text/html'
    s = Session.Session(req)
    if s.is_new():
        s.invalidate()
        return json.dumps({'errorType':ERR_AUTH,
                'errorMessage':"",
                'errorTrace':""})

    strout = websutil.OutputString()
    try:
        s.load()
        username = s['username']
    except:
        traceback.print_exc(file = strout)
        return json.dumps({'errorType':ERR_EXCEPTION,
            'errorMessage':"",
            'errorTrace':strout.get()})

    # Reset the timeout
    s.save()

    archiveValidationResult = websutil.validate_md5_submission(courseId, assignmentId, username, archiveFileName)
    if not(archiveValidationResult == "ok"):
        return json.dumps({'status':False, 'error':archiveValidationResult});

    # Call submit.py
    ## Redirect stdout to catch logging messages from submit
    strout = websutil.OutputString()
    sys.stdout = strout

    try:
        submit.evaluate_large_submission(archiveFileName, assignmentId, username, courseId)
    except submit.SubmittedTooSoonError:
        traceback.print_exc(file = strout)
        return json.dumps({'errorType':ERR_EXCEPTION,
            'errorMessage':"Tema trimisa prea curand",
            'errorTrace':strout.get()})

    except:
        traceback.print_exc(file = strout)
        return json.dumps({'errorType':ERR_EXCEPTION,
            'errorMessage':"",
            'errorTrace':strout.get()})

    # Reset the timeout
    s.save()

    return json.dumps({'status':True,
                       'dumpLog':strout.get()})
Example #2
0
def beginEvaluation(req, courseId, assignmentId, archiveFileName):
    """ Saves a temp file of the uploaded archive and calls
        vmchecker.submit.submit method to put the homework in
        the testing queue"""

    # Check permission
    req.content_type = 'text/html'
    s = Session.Session(req)
    if s.is_new():
        s.invalidate()
        return json.dumps({'errorType':ERR_AUTH,
                'errorMessage':"",
                'errorTrace':""})

    strout = websutil.OutputString()
    try:
        s.load()
        username = s['username']
    except:
        traceback.print_exc(file = strout)
        return json.dumps({'errorType':ERR_EXCEPTION,
            'errorMessage':"",
            'errorTrace':strout.get()})

    # Reset the timeout
    s.save()

    archiveValidationResult = websutil.validate_md5_submission(courseId, assignmentId, username, archiveFileName)
    if not(archiveValidationResult == "ok"):
        return json.dumps({'status':False, 'error':archiveValidationResult});

    # Call submit.py
    ## Redirect stdout to catch logging messages from submit
    strout = websutil.OutputString()
    sys.stdout = strout

    try:
        submit.evaluate_large_submission(archiveFileName, assignmentId, username, courseId)
    except submit.SubmittedTooSoonError:
        traceback.print_exc(file = strout)
        return json.dumps({'errorType':ERR_EXCEPTION,
            'errorMessage':"Tema trimisa prea curand",
            'errorTrace':strout.get()})

    except:
        traceback.print_exc(file = strout)
        return json.dumps({'errorType':ERR_EXCEPTION,
            'errorMessage':"",
            'errorTrace':strout.get()})

    # Reset the timeout
    s.save()

    return json.dumps({'status':True,
                       'dumpLog':strout.get()})
Example #3
0
def beginEvaluation(username, courseId, assignmentId, archiveFileName):
    strout = websutil.OutputString()
    archiveValidationResult = websutil.validate_md5_submission(courseId, assignmentId, username, archiveFileName)
    if not(archiveValidationResult == "ok"):
        return json.dumps({'status':False, 'error':archiveValidationResult});
    # Call submit.py
    ## Redirect stdout to catch logging messages from submit
    strout = websutil.OutputString()
    sys.stdout = strout
    try:
        submit.evaluate_large_submission(archiveFileName, assignmentId, username, courseId)
    except submit.SubmittedTooSoonError:
        traceback.print_exc(file = strout)
        return json.dumps({'errorType':ERR_EXCEPTION,
            'errorMessage':"Tema trimisa prea curand",
            'errorTrace':strout.get()})
    except:
        traceback.print_exc(file = strout)
        return json.dumps({'errorType':ERR_EXCEPTION,
            'errorMessage':"",
            'errorTrace':strout.get()})
    return json.dumps({'status':True,
                       'dumpLog':strout.get()})
Example #4
0
def beginEvaluation(req,
                    courseId,
                    assignmentId,
                    archiveFileName,
                    locale=websutil.DEFAULT_LOCALE):
    """ Saves a temp file of the uploaded archive and calls
        vmchecker.submit.submit method to put the homework in
        the testing queue"""

    websutil.install_i18n(websutil.sanityCheckLocale(locale))

    websutil.sanityCheckAssignmentId(assignmentId)
    websutil.sanityCheckCourseId(courseId)
    # TODO archiveFileName
    websutil.sanityCheckDotDot(archiveFileName)

    # Check permission
    req.content_type = 'text/html'
    s = Session.Session(req)
    if s.is_new():
        s.invalidate()
        return json.dumps({
            'errorType': websutil.ERR_AUTH,
            'errorMessage': "",
            'errorTrace': ""
        })

    strout = websutil.OutputString()
    try:
        s.load()
        username = s['username']
    except:
        traceback.print_exc(file=strout)
        return json.dumps({
            'errorType': websutil.ERR_EXCEPTION,
            'errorMessage': "",
            'errorTrace': strout.get()
        })

    # Reset the timeout
    s.save()

    (_, account) = websutil.getAssignmentAccountName(courseId, assignmentId,
                                                     username, strout)
    archiveValidationResult = websutil.validate_md5_submission(
        courseId, assignmentId, account, archiveFileName)
    if not (archiveValidationResult[0]):
        return json.dumps({
            'status': False,
            'error': archiveValidationResult[1]
        })

    # Call submit.py
    ## Redirect stdout to catch logging messages from submit
    sys.stdout = strout

    try:
        submit.evaluate_large_submission(archiveFileName, assignmentId,
                                         account, courseId)
    except submit.SubmittedTooSoonError:
        traceback.print_exc(file=strout)
        return json.dumps({
            'errorType':
            websutil.ERR_EXCEPTION,
            'errorMessage':
            _("The assignment was submitted too soon"),
            'errorTrace':
            strout.get()
        })
    except submit.SubmittedTooLateError:
        traceback.print_exc(file=strout)
        return json.dumps({
            'errorType':
            websutil.ERR_EXCEPTION,
            'errorMessage':
            _("The assignment was submitted too late"),
            'errorTrace':
            strout.get()
        })
    except:
        traceback.print_exc(file=strout)
        return json.dumps({
            'errorType': websutil.ERR_EXCEPTION,
            'errorMessage': "",
            'errorTrace': strout.get()
        })

    # Reset the timeout
    s.save()

    return json.dumps({'status': True, 'dumpLog': strout.get()})
Example #5
0
def beginEvaluation(req, courseId, assignmentId, archiveFileName, locale=websutil.DEFAULT_LOCALE):
    """ Saves a temp file of the uploaded archive and calls
        vmchecker.submit.submit method to put the homework in
        the testing queue"""

    websutil.install_i18n(websutil.sanityCheckLocale(locale))

    websutil.sanityCheckAssignmentId(assignmentId)
    websutil.sanityCheckCourseId(courseId)
    # TODO archiveFileName
    websutil.sanityCheckDotDot(archiveFileName)

    # Check permission
    req.content_type = 'text/html'
    s = Session.Session(req)
    if s.is_new():
        s.invalidate()
        return json.dumps({'errorType':websutil.ERR_AUTH,
                'errorMessage':"",
                'errorTrace':""})

    strout = websutil.OutputString()
    try:
        s.load()
        username = s['username']
    except:
        traceback.print_exc(file = strout)
        return json.dumps({'errorType':websutil.ERR_EXCEPTION,
            'errorMessage':"",
            'errorTrace':strout.get()})

    # Reset the timeout
    s.save()

    (_, account) = websutil.getAssignmentAccountName(courseId, assignmentId, username, strout)
    archiveValidationResult = websutil.validate_md5_submission(courseId, assignmentId, account, archiveFileName)
    if not(archiveValidationResult[0]):
        return json.dumps({'status' : False, 'error' : archiveValidationResult[1]});

    # Call submit.py
    ## Redirect stdout to catch logging messages from submit
    sys.stdout = strout

    try:
        submit.evaluate_large_submission(archiveFileName, assignmentId, account, courseId)
    except submit.SubmittedTooSoonError:
        traceback.print_exc(file = strout)
        return json.dumps({'errorType':websutil.ERR_EXCEPTION,
            'errorMessage':_("The assignment was submitted too soon"),
            'errorTrace':strout.get()})
    except submit.SubmittedTooLateError:
        traceback.print_exc(file = strout)
        return json.dumps({'errorType':websutil.ERR_EXCEPTION,
            'errorMessage':_("The assignment was submitted too late"),
            'errorTrace':strout.get()})
    except:
        traceback.print_exc(file = strout)
        return json.dumps({'errorType':websutil.ERR_EXCEPTION,
            'errorMessage':"",
            'errorTrace':strout.get()})

    # Reset the timeout
    s.save()

    return json.dumps({'status':True,
                       'dumpLog':strout.get()})