Пример #1
0
def jskdataupdate():  #计蒜客数据更新
    students = Student.objects.all()
    suc = ''
    fail = ''
    strs = ''
    logger = logging.getLogger('log')
    for stu in students:
        if stu.jskID:
            logger.info(stu.realName + "start jsk dataget")
            p = jsk.getjskdata(stu)
            if p:
                suc += stu.realName + '、'
            else:
                fail += stu.realName + '、'
            logger.info(stu.realName + "end jsk dataget")
    datautils.setContestJoinNumbers()
    strs = "successlist:\n" + suc + "\nerrorlist:\n" + fail
    logger.info(strs)
    timelist = json.load(
        open(
            os.path.join(os.path.abspath(os.path.dirname(__file__)),
                         "updatetime.json"), "r"))
    timelist['jskUpdatTime'] = time.strftime("%Y-%m-%d %H:%M:%S",
                                             time.localtime(time.time()))
    json.dump(
        timelist,
        open(
            os.path.join(os.path.abspath(os.path.dirname(__file__)),
                         "updatetime.json"), "w"))
Пример #2
0
def updatestudentlist(request):
    students = []
    for s in AddStudentqueue.objects.all():
        if s.execution_statu == False and str(s.execution) != "None":
            if s.execution == True:
                sc = Student.objects.filter(stuNO=s.stuNO,
                                            realName=s.realName,
                                            className=s.className)
                if len(sc) == 0:
                    Student.objects.create(
                        stuNO=s.stuNO,
                        realName=s.realName,
                        className=s.className,
                        school=s.school,
                        year=s.year,
                        acID=s.acID,
                        cfID=s.cfID,
                        vjID=s.vjID,
                        ncID=s.ncID,
                    )
                    a = Student.objects.get(stuNO=s.stuNO,
                                            realName=s.realName,
                                            className=s.className,
                                            school=s.school)
                else:
                    """sc.update(
                    stuNO=s.stuNO,realName=s.realName,className=s.className,school=s.school,
                    year=s.year,acID=s.acID,cfID=s.cfID,vjID=s.vjID,ncID=s.ncID,
                    )"""#全量修改
                    a = Student.objects.get(stuNO=s.stuNO)
                    if s.acID != '':
                        a.acID = s.acID
                    if s.cfID != '':
                        a.cfID = s.cfID
                    if s.ncID != '':
                        a.ncID = s.ncID
                    if s.vjID != '':
                        a.vjID = s.vjID
                datautils.saveCFdataByUser(a)
                datautils.saveACData(a)
                datautils.saveNCData(a)
                students.append(a)
            s.execution_statu = True
            s.execution_time = time.strftime('%Y-%m-%d %H:%M:%S',
                                             time.localtime(time.time()))
            s.save()
    contests = Contest.objects.filter(ctype='cf')
    for contest in contests:
        datautils.setcontestsolve(contest.cid)
    for stu in students:
        datautils.setaftersolve(stu)
    datautils.setContestJoinNumbers()
    studentlist = AddStudentqueue.objects.order_by("-request_time").all()
    context = {'studentlist': studentlist}
    return render(request, 'addstudentslist.html', context)
Пример #3
0
def getNCData(request):
    studentlist = Student.objects.all()
    # studentlist = Student.objects.filter(realName='张世东')
    str = "NC Data, successed list:"
    logger = logging.getLogger('log')
    for stu in studentlist:
        logger.info(stu.realName + "start nc data")
        datautils.saveNCData(stu)
        str += stu.realName + ","
        logger.info(stu.realName + "end nc data")
    context = {'str': str}
    datautils.setContestJoinNumbers()
    return render(request, 'spiderResults.html', context)
Пример #4
0
def fixbug(request):
    # fix the diff is 0 of ac data
    studentlist = Student.objects.all()
    str = ""
    logger = logging.getLogger('log')
    for stu in studentlist:
        logger.info(stu.realName + "start ac data")
        datautils.saveACData_fixbug(stu)
        str += stu.realName + ","
        logger.info(stu.realName + "end ac data")
    datautils.setContestJoinNumbers()
    context = {'str': str}
    return render(request, 'fixbug.html', context)
Пример #5
0
def getCFData(request):
    studentlist = Student.objects.all()
    str = "CF Data, successed list:"
    log = logging.getLogger("log")
    log.info("getCFData start")
    count = 0
    for stu in studentlist:
        count += 1
        text = "getCFData start %d/%d: %s" % (count, len(studentlist),
                                              stu.realName)
        log.info(text)
        datautils.saveCFdataByUser(stu)
        str += stu.realName + ","
        log.info("getCFData end:" + stu.realName)
    context = {'str': str}
    strs = datautils.cftimeStandard()
    datautils.setContestJoinNumbers()
    contests = Contest.objects.filter(ctype='cf')
    for contest in contests:
        datautils.setcontestsolve(contest.cid)
    return render(request, 'spiderResults.html', context)
Пример #6
0
def getNCData():  #newcoder信息更新
    studentlist = Student.objects.all()
    str = "NC Data, successed list:"
    logger = logging.getLogger('log')
    for stu in studentlist:
        logger.info(stu.realName + "start nc data")
        datautils.saveNCData(stu)
        str += stu.realName + ","
        logger.info(stu.realName + "end nc data")
    context = {'str': str}
    datautils.setContestJoinNumbers()
    timelist = json.load(
        open(
            os.path.join(os.path.abspath(os.path.dirname(__file__)),
                         "updatetime.json"), "r"))
    timelist['ncUpdateTime'] = time.strftime("%Y-%m-%d %H:%M:%S",
                                             time.localtime(time.time()))
    json.dump(
        timelist,
        open(
            os.path.join(os.path.abspath(os.path.dirname(__file__)),
                         "updatetime.json"), "w"))