Example #1
0
def pageMonitorAction():
    plist = ProjectModule.getAllList()
    logs = []
    tmp = []
    for item in plist:
        pcode = ProjectModule.checkPageStatus(item.url)
        pcode = int(pcode)
        print pcode
        print item.url
        if type(pcode) is types.IntType:
            #正常返回了状态
            if 200 == pcode:
                #走内容检查流程
                item.content = item.content.strip()
                try:
                    clist = ProjectModule.checkPageKeywords(item.type.split(","),item.content,item.url)
                    for citem in clist:
                        cstatus = 2 if citem[0] else 1
                        tmp = [citem[0],item.id,item.group_id,pcode,cstatus,citem[1]]
                        logs.append(tmp)
                except:
                    cstatus =2
            else:
                #状态失败,写入日志
                tmp = [False,item.id,item.group_id,pcode,1,'状态错误']
                logs.append(tmp)
    version = ProjectModule.get_release_version()
    monitor_id = ProjectModule.writeLog(logs,version)
#    ProjectModule.sendMail(monitor_id)

    return True
Example #2
0
def create(request):
    print (request.method)
    if request.method == 'POST':
        form = NewProject(request.POST)
        if form.is_valid():
            user_info = User.objects.get(id=request.user.pk)
            if 'id' in request.GET:
                projectId = ProjectModule.update(id=request.GET['id'],data=form.cleaned_data, user=user_info.get_full_name())
            else:
                projectId = ProjectModule.create(data=form.cleaned_data, user=user_info.get_full_name())
            return redirect("/pagemonitor/" )
    else:
        form = NewProject(initial={'createPerson': request.user.first_name})
    return render(request, 'pagemonitor/create.html', {'form': form, 'data': {
        'channelName': CHANNEL,
    }})
Example #3
0
def list(request,group_id = 0):
    q = __buildQuery(query=request.GET.get('q'), group_id=group_id)
    projects, pager = ProjectModule.getProjects(q=q, page=request.GET.get('page', '1'))
    return render(request, 'pagemonitor/list.html', {'data': {
       'q': request.GET.get('q'),
       'projects': projects,
       'pager': pager,
       'group_types': get_group(),
       'channelName': CHANNEL,
       'tab':int(group_id),
    }})