Ejemplo n.º 1
0
def ls_log(request):
    sys_id = request.GET.get('sys_id','')
    mod_id = request.GET.get('mod_id','')
    func_id = request.GET.get('func_id','')
    start = request.GET.get('start','')
    if start != '':
        start = datetime.strptime(start+':00','%Y-%m-%d %X')
    end = request.GET.get('end','')
    if end != '':
        end = datetime.strptime(end+':00','%Y-%m-%d %X')

    if sys_id !='' and mod_id == '':
        mods = ModuleModel.objects(sys_id = sys_id)
        if start == '' and end == '':
            log = LogModel.objects(mod_id__in = [mod.id for mod in mods]).order_by('-time')
        if start != '' and end == '':
            log = LogModel.objects(mod_id__in = [mod.id for mod in mods],time__gte=start).order_by('-time')
        if start == '' and end != '':
            log = LogModel.objects(mod_id__in = [mod.id for mod in mods],time__lte=end).order_by('-time')
        if start != '' and end != '':
            log = LogModel.objects(mod_id__in = [mod.id for mod in mods],time__gte=start,time__lte=end).order_by('-time')

    if mod_id != '' and func_id == '':
        if start == '' and end == '':
            log = LogModel.objects(mod_id = mod_id).order_by('-time')
        if start != '' and end == '':
            log = LogModel.objects(mod_id = mod_id,time__gte=start).order_by('-time')
        if start == '' and end != '':
            log = LogModel.objects(mod_id = mod_id,time__lte=end).order_by('-time')
        if start != '' and end != '':
            log = LogModel.objects(mod_id = mod_id,time__gte=start,time__lte=end).order_by('-time')
        #log = LogModel.objects(__raw__={'mod_id':mod_id})

    if func_id != '':
        #log = LogModel.objects(mod_id = mod_id,time__gte=start+':00',time__lte=end+':00')
        if start == '' and end == '':
            log = LogModel.objects(func_id = func_id).order_by('-time')
        if start != '' and end == '':
            log = LogModel.objects(func_id = func_id ,time__gte=start).order_by('-time')
        if start == '' and end != '':
            log = LogModel.objects(func_id = func_id ,time__lte=end).order_by('-time')
        if start != '' and end != '':
            log = LogModel.objects(func_id = func_id ,time__gte=start,time__lte=end).order_by('-time')
    if log:
        mod = ModuleModel.objects(id = log[0].mod_id)
        sys_id = mod[0].sys_id

    kn = KeynameModel.objects(sys_id = sys_id)
    keyname = {}
    for k in kn:
        keyname[k.key] = k.name

    t = get_template('log/index.html')
    html = t.render(Context({'logs':log,'detail':'detail','sys_id':sys_id,'mod_id':mod_id,'start':start,'end':end,'keyname':keyname}))
    return HttpResponse(html)
Ejemplo n.º 2
0
def add_mod(request):
    sys_id = request.POST.get('sys_id')
    name = request.POST.get('name')
    if sys_id is None or name is None:
        return HttpResponse(ret)
    mod = ModuleModel()
    mod.sys_id = sys_id
    mod.name = name
    mod.save()
    if mod.id:
        msg = 'succ'
    return HttpResponse(msg)
Ejemplo n.º 3
0
    func_name = request.POST['func']
    try:
        open('/tmp/get','a').write(repr(request.POST)+'\n')
    except Exception,e:
        open('/tmp/get','a').write(e+'\n')

    sys = SystemModel.objects(name = sys_name)
    if not sys:
        sys = SystemModel()
        sys.name = sys_name
        sys.save()
        sys_id = sys.id
    else:
        sys_id = sys[0].id

    mod = ModuleModel.objects(sys_id = sys_id,name = mod_name)
    if not mod:
        mod = ModuleModel()
        mod.sys_id = sys_id
        mod.name = mod_name
        mod.save()
        mod_id = mod.id
    else:
        mod_id = mod[0].id

    func = FuncModel.objects(mod_id = mod_id,name = func_name)
    if not func:
        func = FuncModel()
        func.mod_id = mod_id
        func.name = func_name
        func.save()
Ejemplo n.º 4
0
def ls_mod(request):
    sys_id = request.GET['sys_id']
    mod = ModuleModel.objects(sys_id=sys_id)
    t = get_template('module/index.html')
    html = t.render(Context({'mod':mod}))
    return HttpResponse(html)
Ejemplo n.º 5
0
def up_mod(request):
    mod_id = '50c1994c14908d14c1069699'
    mod = ModuleModel(id=mod_id)
    mod.name = 'test'
    mod.save()
    return HttpResponse('a')