#task_histories
This commit is contained in:
parent
1b3533d2c1
commit
7b8314cb6e
|
@ -6,4 +6,5 @@ urlpatterns = [
|
|||
path('monotoring/',views.monotoring),
|
||||
path('alarm/',views.alarm),
|
||||
path('task/histories/',views.task_histories),
|
||||
path('task/histories/detail/<str:pk>/',views.task_histories_detail),
|
||||
]
|
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
|
||||
from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
|
||||
from django.db import connection
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import render
|
||||
|
@ -125,13 +126,13 @@ def task_histories(request):
|
|||
o['data'] = output_list[1]
|
||||
o['msg'] = output_list[2]
|
||||
|
||||
|
||||
task.append(o)
|
||||
with connection.cursor() as cursor1:
|
||||
cursor1.execute("select * from tasks where id = '%s'" % (id))
|
||||
row1 = cursor1.fetchall()
|
||||
for r1 in row1:
|
||||
o1 = dict()
|
||||
o1['id'] = r1[0]
|
||||
o1['name'] = r1[1]
|
||||
o1['type'] = r1[2]
|
||||
o1['desc'] = r1[8]
|
||||
|
@ -141,3 +142,37 @@ def task_histories(request):
|
|||
"status": "1",
|
||||
"res": res
|
||||
}))
|
||||
|
||||
|
||||
def task_histories_detail(request, pk):
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute("select * from task_histories where task_id = '%s';" % (pk))
|
||||
row = cursor.fetchall()
|
||||
paginator = Paginator(row, 10)
|
||||
page = int(request.GET.get('page', 1))
|
||||
try:
|
||||
row = paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
row = paginator.page(1)
|
||||
except EmptyPage:
|
||||
row = paginator.page(paginator.num_pages)
|
||||
res = []
|
||||
print(row)
|
||||
for r in row:
|
||||
o = dict()
|
||||
o['id'] = r[0]
|
||||
o['task_id'] = r[1]
|
||||
o['status'] = r[2]
|
||||
o['run_time'] = r[3]
|
||||
output = str(r[4])[1:-1].split(',')[3][2:-2]
|
||||
output_list = str(output).split('\\n')
|
||||
o['output'] = str(r[4])[1:-1]
|
||||
o['success'] = output_list[0]
|
||||
o['data'] = output_list[1]
|
||||
o['msg'] = output_list[2]
|
||||
res.append(o)
|
||||
print(r)
|
||||
return HttpResponse(json.dumps({
|
||||
"status":"1",
|
||||
"res":res
|
||||
}))
|
||||
|
|
Loading…
Reference in New Issue