Example #1
0
def jobadd(request):
    islogin = request.COOKIES.get('islogin', False)
    username = request.COOKIES.get('username', '')
    response_data = {}
    response_data['result'] = '0'
    if islogin == False:
        print '未登录'
        return HttpResponse(json.dumps(response_data,
                                       skipkeys=True,
                                       default=webtool.object2dict),
                            content_type="application/json")
    job, result = jobcontrol.loadjob(request, username=username)
    if result == False:
        print '作业不完善'
        return HttpResponse(json.dumps(response_data,
                                       skipkeys=True,
                                       default=webtool.object2dict),
                            content_type="application/json")

    result = jobcontrol.jobadd(job)
    #     print result
    if result:
        print '操作成功'
        response_data['result'] = '1'
    return HttpResponse(json.dumps(response_data,
                                   skipkeys=True,
                                   default=webtool.object2dict),
                        content_type="application/json")
Example #2
0
def addjob(request):
    islogin = request.COOKIES.get('islogin', False)
    username = request.COOKIES.get('username', '')
    response_data = {}
    response_data['result'] = '0'

    if islogin == False:
        print '未登录'
        return HttpResponse(json.dumps(response_data, skipkeys=True, default=webtool.object2dict), \
                content_type="application/json")
    # 扫描地址或者端口不为空,就对填写的job信息进行获取,并初始化job对象, result=True
    job, result = jobcontrol.loadjob(request, username=username)

    if result == False:
        print '信息不完善(请检查扫描地址和端口信息,重新添加)'
        return HttpResponse(json.dumps(response_data,
                                       skipkeys=True,
                                       default=webtool.object2dict),
                            content_type="application/json")

    result = jobcontrol.jobadd(job)
    print "==========================debug::jobadd()==========================", result
    if result:
        print '操作成功'
        response_data['result'] = '1'
    return HttpResponse(json.dumps(response_data,
                                   skipkeys=True,
                                   default=webtool.object2dict),
                        content_type="application/json")
Example #3
0
def jobadd(request):
    islogin = request.COOKIES.get('islogin',False)
    username = request.COOKIES.get('username','')
    response_data = {}  
    response_data['result'] = '0' 
    if islogin ==False:
        print '未登录'
        return HttpResponse(json.dumps(response_data,skipkeys=True,default=webtool.object2dict), content_type="application/json")  
    job,result=jobcontrol.loadjob(request,username=username)
    if result==False:
        print '作业不完善'
        return HttpResponse(json.dumps(response_data,skipkeys=True,default=webtool.object2dict), content_type="application/json")  
 
    result=jobcontrol.jobadd(job)
#     print result
    if result:
        print '操作成功'
        response_data['result'] = '1' 
    return HttpResponse(json.dumps(response_data,skipkeys=True,default=webtool.object2dict), content_type="application/json")