Ejemplo n.º 1
0
def to_process_written_code(pageNum, problemIndex):
    memberId = session[SessionResources().const.MEMBER_ID]
    memberIdIndex = session[SessionResources().const.MEMBER_ID_INDEX]
    problemName = remove_space_in_problemName(problemIndex)
    filePath, tempPath = make_path(PATH, memberIdIndex, memberId, problemName)
    try:
        os.mkdir(tempPath)
        usedLanguageName, usedLanguageVersion, fileName = write_code_in_file(
            tempPath)
        fileSize = os.stat(os.path.join(tempPath, fileName)).st_size
        fileIndex = 1
        submissionIndex = get_submission_index(memberIdIndex, problemIndex)
        delete_submitted_files_data(submissionIndex)
        insert_submitted_files(submissionIndex, fileIndex, fileName, filePath,
                               fileSize)
        send_to_celery(memberIdIndex, problemIndex, submissionIndex,
                       usedLanguageName, usedLanguageVersion, fileSize,
                       problemName, filePath, tempPath)
        Log.info(OtherResources().const.WRITED_CODE_SUBMITTED)
    except OSError as e:
        Log.error(str(e))
        submit_error(tempPath, pageNum, OtherResources().const.FILE_ERROR)
    except Exception as e:
        dao.rollback()
        Log.error(str(e))
        print e
        submit_error(tempPath, pageNum, OtherResources().const.DB_ERROR)

    time.sleep(0.4)

    return page_move(pageNum)
def to_process_written_code(pageNum, problemIndex):
    memberId = session[SessionResources().const.MEMBER_ID]
    memberIdIndex = session[SessionResources().const.MEMBER_ID_INDEX]
    problemName = remove_space_in_problemName(problemIndex)
    filePath, tempPath = make_path(PATH, memberIdIndex, memberId, problemName)
    try:
        os.mkdir(tempPath)
        usedLanguageName, usedLanguageVersion, fileName = write_code_in_file(tempPath)
        fileSize = os.stat(os.path.join(tempPath, fileName)).st_size
        fileIndex = 1
        submissionIndex = get_submission_index(memberIdIndex, problemIndex)
        delete_submitted_files_data(submissionIndex)
        insert_submitted_files(submissionIndex, fileIndex, fileName, filePath, fileSize)
        send_to_celery(memberIdIndex, problemIndex, submissionIndex, usedLanguageName, usedLanguageVersion, fileSize, problemName, filePath, tempPath)
        Log.info(OtherResources().const.WRITED_CODE_SUBMITTED)
    except OSError as e:
        Log.error(str(e))
        submit_error(tempPath, pageNum, OtherResources().const.FILE_ERROR)
    except Exception as e:
        dao.rollback()
        Log.error(str(e))
        print e
        submit_error(tempPath, pageNum, OtherResources().const.DB_ERROR)
        
    time.sleep(0.4)
    
    return page_move(pageNum)
def to_process_uploaded_files(problemIndex, pageNum, browserName, browserVersion):
    memberId = session[SessionResources().const.MEMBER_ID]
    memberIdIndex = session[SessionResources().const.MEMBER_ID_INDEX]
    problemName = remove_space_in_problemName(problemIndex)
    filePath, tempPath = make_path(PATH, memberIdIndex, memberId, problemName)

    try:
        os.mkdir(tempPath)
        uploadFiles = request.files.getlist(OtherResources().const.GET_FILES)
        usedLanguageName = request.form[OtherResources().const.USED_LANGUAGE_NAME]
        usedLanguageVersion = request.form[OtherResources().const.USED_LANGUAGE_VERSION]
        submissionIndex = get_submission_index(memberIdIndex, problemIndex)
        sumOfSubmittedFileSize = file_save(submissionIndex, uploadFiles, tempPath, filePath)
        send_to_celery(memberIdIndex, problemIndex, submissionIndex, usedLanguageName, usedLanguageVersion, sumOfSubmittedFileSize, problemName, filePath, tempPath)
        Log.info(OtherResources().const.FILE_SUBMITTED)
    except OSError as e:
        Log.error(str(e))
        submit_error(tempPath, pageNum, OtherResources().const.FILE_ERROR, browserName, browserVersion)
    except Exception as e:
        dao.rollback()
        Log.error(str(e))
        print e
        submit_error(tempPath, pageNum, OtherResources().const.DB_ERROR, browserName, browserVersion)
        
    time.sleep(0.4)
    
    return page_move(pageNum, browserName, browserVersion)
Ejemplo n.º 4
0
def to_process_uploaded_files(problemIndex, pageNum, browserName,
                              browserVersion):
    memberId = session[SessionResources().const.MEMBER_ID]
    memberIdIndex = session[SessionResources().const.MEMBER_ID_INDEX]
    problemName = remove_space_in_problemName(problemIndex)
    filePath, tempPath = make_path(PATH, memberIdIndex, memberId, problemName)

    try:
        os.mkdir(tempPath)
        uploadFiles = request.files.getlist(OtherResources().const.GET_FILES)
        usedLanguageName = request.form[
            OtherResources().const.USED_LANGUAGE_NAME]
        usedLanguageVersion = request.form[
            OtherResources().const.USED_LANGUAGE_VERSION]
        submissionIndex = get_submission_index(memberIdIndex, problemIndex)
        sumOfSubmittedFileSize = file_save(submissionIndex, uploadFiles,
                                           tempPath, filePath)
        send_to_celery(memberIdIndex, problemIndex, submissionIndex,
                       usedLanguageName, usedLanguageVersion,
                       sumOfSubmittedFileSize, problemName, filePath, tempPath)
        Log.info(OtherResources().const.FILE_SUBMITTED)
    except OSError as e:
        Log.error(str(e))
        submit_error(tempPath, pageNum,
                     OtherResources().const.FILE_ERROR, browserName,
                     browserVersion)
    except Exception as e:
        dao.rollback()
        Log.error(str(e))
        print e
        submit_error(tempPath, pageNum,
                     OtherResources().const.DB_ERROR, browserName,
                     browserVersion)

    time.sleep(0.4)

    return page_move(pageNum, browserName, browserVersion)