Exemplo n.º 1
0
def task_tail(req,domain):
    user     = req.user
    if req.method == 'GET' and 'uuid' in req.GET:
        uid = req.GET['uuid']
        try:
            hd = sql_sd.select('192.168.3.120','run_log','scrapy',uuid=uid)
            h_d = list(hd[14:26])
            if not hd[24]:
                h_d[-2] = 0 
            sd   = json.dumps({'result':h_d}) 
        except:
            sd   = json.dumps({}) 
        return HttpResponse(sd)
    conn     = MySQLdb.connect(host='192.168.3.120',user='******',passwd='root',db='run_log')
    cur      = conn.cursor()
    hour_data= cur.execute("""select start.uuid,category_name,domain,domain_name, config_url,priority_seconds,
                            from_unixtime(start_datetime+(3600*8)),tag,from_unixtime(end_datetime+(3600*8)),
                            result_code,(end_datetime - start_datetime),start_datetime from
                            task_start_log as start join task_end_log as end on start.uuid=end.uuid where domain=%s""",(domain))
    hd       = cur.fetchall()
    cur.close()
    conn.close()
    uuid     = [i[0] for i in hd]
    h_d      = json.dumps([[h[-1],h[-2],h[0]] for h in hd])
    return render_to_response('task_tail.html',{'user':user,'hd':hd,'h_d':h_d,'domain':domain})
Exemplo n.º 2
0
def task_tail(req, domain):
    user = req.user
    if req.method == 'GET' and 'uuid' in req.GET:
        uid = req.GET['uuid']
        try:
            hd = sql_sd.select('192.168.3.120', 'run_log', 'scrapy', uuid=uid)
            h_d = list(hd[14:26])
            if not hd[24]:
                h_d[-2] = 0
            sd = json.dumps({'result': h_d})
        except:
            sd = json.dumps({})
        return HttpResponse(sd)
    conn = MySQLdb.connect(host='192.168.3.120',
                           user='******',
                           passwd='root',
                           db='run_log')
    cur = conn.cursor()
    hour_data = cur.execute(
        """select start.uuid,category_name,domain,domain_name, config_url,priority_seconds,
                            from_unixtime(start_datetime+(3600*8)),tag,from_unixtime(end_datetime+(3600*8)),
                            result_code,(end_datetime - start_datetime),start_datetime from
                            task_start_log as start join task_end_log as end on start.uuid=end.uuid where domain=%s""",
        (domain))
    hd = cur.fetchall()
    cur.close()
    conn.close()
    uuid = [i[0] for i in hd]
    h_d = json.dumps([[h[-1], h[-2], h[0]] for h in hd])
    return render_to_response('task_tail.html', {
        'user': user,
        'hd': hd,
        'h_d': h_d,
        'domain': domain
    })
Exemplo n.º 3
0
def config_error(req):
    user = req.user
    ce = sql_sd.select('192.168.3.120', 'run_log', 'config_error')[::-1]
    return render_to_response('config_error.html', {
        'user': user,
        'config_error': ce
    })
Exemplo n.º 4
0
def spider_server(req):
    user = req.user
    server_list = sql_sd.select('192.168.3.130', 'task', 'spider_server',
                                'status')
    ssl = [[
        s[1], s[2], s[3], s[4],
        time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(s[5]))), s[0]
    ] for s in server_list]
    return render_to_response('spider_server.html', {'user': user, 'ssl': ssl})
Exemplo n.º 5
0
def task_list(req):
    user = req.user
    task = sql_sd.select('192.168.3.109', 'task', 'task_list',
                         'start_datetime')[::-1]
    task_list = [
        i + (int(i[17]) - int(i[16]),
             time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(i[16])))
        for i in task
    ]
    return render_to_response('task_list.html', {
        'user': user,
        'task_list': task_list
    })
Exemplo n.º 6
0
def http_status(req):
    user     = req.user
    hd       = sql_sd.select('192.168.3.120','run_log','scrapy','response_count')
    return render_to_response('http_status.html',{'user':user,'hd':hd})
Exemplo n.º 7
0
def config_error(req):
    user     = req.user
    ce       = sql_sd.select('192.168.3.120','run_log','config_error')[::-1]
    return render_to_response('config_error.html',{'user':user,'config_error':ce})
Exemplo n.º 8
0
def task_list(req):
    user     = req.user
    task     = sql_sd.select('192.168.3.109','task','task_list','start_datetime')[::-1]
    task_list= [i+(int(i[17]) - int(i[16]),time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(i[16]))) for i in task]
    return render_to_response('task_list.html',{'user':user,'task_list':task_list})
Exemplo n.º 9
0
def spider_server(req):
    user     = req.user
    server_list = sql_sd.select('192.168.3.130','task','spider_server','status')
    ssl      = [[s[1],s[2],s[3],s[4],time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(int(s[5]))),s[0]] for s in server_list]
    return render_to_response('spider_server.html',{'user':user,'ssl':ssl})
Exemplo n.º 10
0
def http_status(req):
    user = req.user
    hd = sql_sd.select('192.168.3.120', 'run_log', 'scrapy', 'response_count')
    return render_to_response('http_status.html', {'user': user, 'hd': hd})