(request)
return HttpResponse('无日志记录!')
命令历史记录
命令历史记录
命令历史记录
def log_history(request):
    """ 命令历史记录 """
    log_id = request.GET.get('id', 0)
    log = Log.objects.filter(id=log_id)
    if log:
        log = log[0]
        tty_logs = log.ttylog_set.all()

        if tty_logs:
            content = ''
            for tty_log in tty_logs:
                content += '%s: %s\n' % (tty_log.datetime.strftime('%Y-%m-%d %H:%M:%S'), tty_log.cmd)
            return HttpResponse(content)

    return HttpResponse('无日志记录!')
def log_history ( request ) : log_id = request . GET . get ( 'id' , 0 ) log = Log . objects . filter ( id = log_id ) if log : log = log [ 0 ] tty_logs = log . ttylog_set . all ( ) if tty_logs : content = '' for tty_log in tty_logs : content += '%s: %s\n' % ( tty_log . datetime . strftime ( '%Y-%m-%d %H:%M:%S' ) , tty_log . cmd ) return HttpResponse ( content ) return HttpResponse ( '无日志记录!')