mirror of https://github.com/jumpserver/jumpserver
bugfix
parent
7de03c0fc7
commit
cf1da2a420
|
@ -79,6 +79,14 @@ def renderTemplate(script_path, time_file_path, dimensions=(24, 80), templatenam
|
||||||
return rendered
|
return rendered
|
||||||
|
|
||||||
|
|
||||||
|
def renderJSON(script_path, time_file_path):
|
||||||
|
with copen(script_path, encoding='utf-8', errors='replace', newline='\r\n') as scriptf:
|
||||||
|
# with open(script_path) as scriptf:
|
||||||
|
with open(time_file_path) as timef:
|
||||||
|
timing = getTiming(timef)
|
||||||
|
json = scriptToJSON(scriptf, timing)
|
||||||
|
return json
|
||||||
|
|
||||||
def kill_invalid_connection():
|
def kill_invalid_connection():
|
||||||
unfinished_logs = Log.objects.filter(is_finished=False)
|
unfinished_logs = Log.objects.filter(is_finished=False)
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
|
|
|
@ -5,7 +5,7 @@ from django.shortcuts import render_to_response, render
|
||||||
from jumpserver.api import *
|
from jumpserver.api import *
|
||||||
from jperm.perm_api import user_have_perm
|
from jperm.perm_api import user_have_perm
|
||||||
from django.http import HttpResponseNotFound
|
from django.http import HttpResponseNotFound
|
||||||
from jlog.log_api import renderTemplate
|
from jlog.log_api import renderJSON
|
||||||
|
|
||||||
from jlog.models import Log, ExecLog, FileLog, TermLog
|
from jlog.models import Log, ExecLog, FileLog, TermLog
|
||||||
from jumpserver.settings import LOG_DIR
|
from jumpserver.settings import LOG_DIR
|
||||||
|
@ -138,7 +138,14 @@ def log_record(request):
|
||||||
if log_id:
|
if log_id:
|
||||||
TermL = TermLogRecorder(request.user)
|
TermL = TermLogRecorder(request.user)
|
||||||
log = Log.objects.get(id=int(log_id))
|
log = Log.objects.get(id=int(log_id))
|
||||||
return HttpResponse(TermL.load_full_log(filename=log.filename))
|
if len(log.filename) == 0:
|
||||||
|
log_file = log.log_path + '.log'
|
||||||
|
log_time = log.log_path + '.time'
|
||||||
|
if os.path.isfile(log_file) and os.path.isfile(log_time):
|
||||||
|
content = renderJSON(log_file, log_time)
|
||||||
|
return HttpResponse(content)
|
||||||
|
else:
|
||||||
|
return HttpResponse(TermL.load_full_log(filename=log.filename))
|
||||||
else:
|
else:
|
||||||
return HttpResponse("ERROR")
|
return HttpResponse("ERROR")
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue