示例#1
0
文件: views.py 项目: UrQA/URQA-Server
def statistics(request, apikey):
    #통계페이지를 Randering하는 루틴
    username = request.user

    valid, message, userelement, projectelement = validUserPjt(
        username, apikey)

    if not valid:
        return HttpResponseRedirect('/urqa')

    user = AuthUser.objects.get(username=request.user)

    tpl = loader.get_template('statistics.html')

    #userdict = getUserProfileDict(userelement)
    userdict = getUserProfileDict(user)
    apikeydict = getApikeyDict(apikey)
    settingdict = getSettingDict(projectelement, userelement)

    statisticsdict = {
        'ServerURL': 'http://' + request.get_host() + '/urqa/project/',
    }

    ctxdict = dict(userdict.items() + apikeydict.items() +
                   settingdict.items() + statisticsdict.items())
    ctx = Context(ctxdict)

    #return render(request, 'statistics.html', ctx)
    return HttpResponse(tpl.render(ctx))
示例#2
0
def projectdashboard(request, apikey):

    username = request.user

    valid , message , userelement, projectelement = validUserPjt(username,apikey)

    if not valid:
        return HttpResponseRedirect('/urqa')

    print request.META.get('REMOTE_ADDR'),username, projectelement.name

    userdict = getUserProfileDict(userelement)
    apikeydict = getApikeyDict(apikey)
    settingdict = getSettingDict(projectelement,userelement)

    listdict = errorscorelist(apikey)

    dashboarddict = {
        'error_list' : listdict,
        'total_error_counter' :  len(listdict)
    }

    ctx = dict(userdict.items() + apikeydict.items() + settingdict.items() + dashboarddict.items() )

    return render(request, 'projectdashboard.html', ctx)
示例#3
0
def projectdashboard(request, apikey):
    #Project의 데시보드를 랜더링 하는 루틴
    username = request.user

    valid, message, userelement, projectelement = validUserPjt(
        username, apikey)

    if not valid:
        return HttpResponseRedirect('/urqa')

    #print request.META.get('REMOTE_ADDR'),username, projectelement.name

    userdict = getUserProfileDict(userelement)
    apikeydict = getApikeyDict(apikey)
    settingdict = getSettingDict(projectelement, userelement)

    listdict = errorscorelist(apikey)
    #listdict = []

    dashboarddict = {
        'error_list': listdict,
        'total_error_counter': len(listdict)
    }

    ctx = dict(userdict.items() + apikeydict.items() + settingdict.items() +
               dashboarddict.items())

    return render(request, 'projectdashboard.html', ctx)
示例#4
0
def statistics(request,apikey):
    #통계페이지를 Randering하는 루틴
    username = request.user

    valid , message , userelement, projectelement = validUserPjt(username,apikey)

    if not valid:
        return HttpResponseRedirect('/urqa')

    user = AuthUser.objects.get(username = request.user)

    tpl = loader.get_template('statistics.html')

    #userdict = getUserProfileDict(userelement)
    userdict = getUserProfileDict(user)
    apikeydict = getApikeyDict(apikey)
    settingdict = getSettingDict(projectelement,userelement)

    
    statisticsdict = {
        'ServerURL' : 'http://'+request.get_host() + '/urqa/project/',
    }

    ctxdict = dict(userdict.items() + apikeydict.items() + settingdict.items() + statisticsdict.items() )
    ctx = Context(ctxdict)

    #return render(request, 'statistics.html', ctx)
    return HttpResponse(tpl.render(ctx))
示例#5
0
def filter_view(request,apikey):
    username = request.user

    valid , message , userelement, projectelement = validUserPjt(username,apikey)

    if not valid:
        return HttpResponseRedirect('/urqa')

    user = AuthUser.objects.get(username = request.user)

    week, today = getTimeRange(TimeRange.weekly,projectelement.timezone)

    try:
        projectElement = Projects.objects.get(apikey = apikey)
    except ObjectDoesNotExist:
        print 'invalid pid'
        return HttpResponse('')

    errorElements = Errors.objects.filter(pid = projectElement , lastdate__range = (week, today) ).order_by('-errorweight','rank', '-lastdate')
    valid_tag = Tags.objects.filter(pid=projectElement).values('tag').distinct().order_by('tag')
    valid_class = errorElements.values('errorclassname').distinct().order_by('errorclassname')
    valid_app = Appstatistics.objects.filter(iderror__in=errorElements).values('appversion').distinct().order_by('-appversion')
    valid_os = Osstatistics.objects.filter(iderror__in=errorElements).values('osversion').distinct().order_by('-osversion')


    osv_list = []
    os_idx = -1
    prev_v = ['-1','-1','-1']
    for e in valid_os:
        v = e['osversion'].split('.')
        if len(v) < 2:
            v.append(' ')
        if v[0] != prev_v[0] or v[1] != prev_v[1]:
            prev_v = v
            os_idx += 1
            osv_list.append({})
            osv_list[os_idx]['key'] = '%s.%s' % (v[0],v[1])
            osv_list[os_idx]['value'] = []
        osv_list[os_idx]['value'].append(e['osversion'])


    appv_list = []
    app_idx = -1
    prev_v = ['-1','-1','-1']
    for e in valid_app:
        v = e['appversion'].split('.')
        if v[0] != prev_v[0] or v[1] != prev_v[1]:
            prev_v = v
            app_idx += 1
            appv_list.append({})
            appv_list[app_idx]['key'] = '%s.%s' % (v[0],v[1])
            appv_list[app_idx]['value'] = []
        appv_list[app_idx]['value'].append(e['appversion'])


    tag_list = []
    for e in valid_tag:
        tag_list.append(e['tag'])

    class_list = []
    for e in valid_class:
        class_list.append(e['errorclassname'])

    osv_margin = ''
    for i in range(0,5 - len(osv_list)):
        osv_margin += ' '

    appv_margin = ''
    for i in range(0,5 - len(appv_list)):
        appv_margin += ' '

    #tpl = loader.get_template('filter.html')
    filterdict = {
        #'ServerURL' : 'http://'+request.get_host() + '/urqa/project/',
        'tag_list' : tag_list,
        'class_list' : class_list,
        'osv_list' : osv_list,
        'margin' : {'osv':osv_margin,'appv':appv_margin},
        'appv_list' : appv_list,
    }

    userdict = getUserProfileDict(user)
    apikeydict = getApikeyDict(apikey)
    settingdict = getSettingDict(projectelement,user)
    print userdict
    ctxdict  = dict(userdict.items() + apikeydict.items() + settingdict.items() + filterdict.items() )
    ctx = Context(ctxdict);


    #return HttpResponse(tpl.render(ctx))

    return render(request, 'filter.html', ctx)
示例#6
0
def errorDetail(request,apikey,iderror):

    valid , message , user ,ErrorsElement, projectelement = author_check_error_page(request.user, apikey, iderror)
    if not valid:
        print message
        return HttpResponseRedirect('/urqa')

    # Status New일 경우 Open으로 자동변경
    # SuperUser는 자동변경에서 예외
    if not user.is_superuser and ErrorsElement.status == Status.New:
        ErrorsElement.status = Status.Open
        ErrorsElement.save()

    #manual_Auto
    isManual = True
    if ErrorsElement.autodetermine == 1:
        isManual = False
    else:
        isManual = True

    instanceElements = Instances.objects.filter(iderror = ErrorsElement).order_by('-datetime')
    #wifi
    wifi = 0
    wifielements = instanceElements.filter(wifion = 1)
    wifi = len(wifielements)
    #gps
    gps = 0
    gpselements = instanceElements.filter(gpson = 1)
    gps = len(gpselements)
    #mobilenetwork
    mobilenetwork = 0
    mobilenetworkelements = instanceElements.filter(mobileon = 1)
    mobilenetwork = len(mobilenetworkelements)
    numobins = float(ErrorsElement.numofinstances)

    ###taglist###
    tagsElements = Tags.objects.filter(iderror = ErrorsElement)
    taglist = []
    for tag in tagsElements:
        taglist.append(tag.tag)

    ###callstack###
    callstackstr = ErrorsElement.callstack
    if(RANK.Native == ErrorsElement.rank):
        callstackstrlist = callstackstr.split('\n')
    else:
        callstackstrlist = callstackstr.split('\n\t')
    counter = 0
    callstacklist = []
    compile = re.compile('\(.*?:[0-9]*?\)')
    nativecompile = re.compile('\[.*?:.*?\]')

    #print '-----------------------'
    for linstr in callstackstrlist:
        tmp = {'counter' : 0, 'source' : '', 'value' : ''}
        counter += 1
        tmp['counter'] = counter
        tmp['value'] = re.sub('\(.*?:[0-9]*?\)','',linstr)
        #native
        tmp['value'] = re.sub('\[.*?:.*?\]','',tmp['value'])
        #print tmp['value']

        list = compile.findall(linstr)
        nativelist =  nativecompile.findall(linstr)
        source = ''

        if len(list) > 0:
            source = list[0]
        if len(nativelist) > 0:
            source = nativelist[0]

        tmp['source'] = source
        #print tmp['source']
        callstacklist.append(tmp)

    #print '-----------------------'

    ####instance#######
    instancelist = []
    for instance in instanceElements:
        instancetuple = {'datetime' : "", 'osversion' : '','appversion' : '' , 'device' : '', 'country' : '', 'idinstance' : ''}
        adtimezone = toTimezone(instance.datetime,projectelement.timezone)
        instancetuple['date'] = adtimezone.__format__('%Y.%m.%d')
        instancetuple['time'] = adtimezone.__format__('%H:%M:%S')
        instancetuple['osversion'] = instance.osversion
        instancetuple['appversion'] = instance.appversion
        instancetuple['device'] = instance.device
        instancetuple['country'] = instance.country
        instancetuple['idinstance'] = instance.idinstance
        instancelist.append(instancetuple)


    #projectelement = Projects.objects.get(apikey = apikey)
    platformdata = json.loads(get_config('app_platforms'))
    #platformtxt = get_dict_value_matchin_key(platformdata,projectelement.platform)


    CommentElements = Comments.objects.filter(iderror = iderror).order_by('datetime')
    commentlist = []
    for comment in CommentElements:
        commenttuple = {}
        try:
            commentuser = AuthUser.objects.get(id = comment.uid.id)
        except ObjectDoesNotExist:
            continue
        adtimezone = toTimezone(comment.datetime,projectelement.timezone)
        print 'here',adtimezone,comment.datetime
        commenttuple['imagesrc'] = commentuser.image_path
        commenttuple['name'] = commentuser.first_name + ' ' + commentuser.last_name
        commenttuple['comment'] = comment.comment
        commenttuple['date'] = adtimezone.__format__('%Y.%m.%d')
        commenttuple['time'] = adtimezone.__format__('%H:%M:%S')
        commenttuple['ownercomment'] = comment.uid == user and True or False
        commenttuple['id'] = comment.idcomment
        commentlist.append(commenttuple)


    userdict = getUserProfileDict(user)
    apikeydict = getApikeyDict(apikey)
    settingdict = getSettingDict(projectelement,user)

    adtimezone_first = toTimezone(ErrorsElement.createdate,projectelement.timezone)
    adtimezone_last = toTimezone(ErrorsElement.lastdate,projectelement.timezone)
    detaildict = {
        'iderror' : iderror,
        'ErrorScore' : ErrorsElement.errorweight,
        'isManual' :  isManual,
        'ErrorName' : ErrorsElement.errorname,
        'ErrorFile' : '(' +ErrorsElement.errorclassname + ':' + ErrorsElement.linenum + ')',
        'Errornumofinstances' : ErrorsElement.numofinstances,
        'Errorrecur' : ErrorsElement.recur,
        'Errorstatus' : ErrorsElement.status,
        'Errorswifi' : int(wifi/numobins * 100),
        'Errorsgps' : int(gps/numobins * 100),
        'ErrorStatus' : ErrorsElement.status + 1,
        'Errorsmobilenetwork' : int(mobilenetwork/numobins * 100),
        'Errorsmemoryusage' : ErrorsElement.totalmemusage / ErrorsElement.numofinstances,
        'createdate' : adtimezone_first.__format__('%Y.%m.%d'),
        'lastdate' : adtimezone_last.__format__('%Y.%m.%d'),
        'ErrorRankColor' : ErrorsElement.rank == RANK.Suspense and 'Nothing' or RANK.rankcolor[ErrorsElement.rank],
        'isNative' : ErrorsElement.rank == RANK.Native ,
        'tag_list' : taglist,
        'callstack' : callstacklist,
        'instance_list' : instancelist,
        'comment_list' : commentlist,
        'so_file_list' : Sofiles.objects.filter(pid = projectelement)
    }
    ctxdict  = dict(userdict.items() + apikeydict.items() + settingdict.items() + detaildict.items() )

    tpl = loader.get_template('details.html')
    #ctx = Context(ctxdict);
    return render(request,'details.html',ctxdict)
示例#7
0
def filter_view(request, apikey):
    #Filter page를 Randering하는 루틴
    username = request.user

    valid, message, userelement, projectelement = validUserPjt(
        username, apikey)

    if not valid:
        return HttpResponseRedirect('/urqa')

    week, today = getTimeRange(TimeRange.weekly, projectelement.timezone)

    try:
        projectElement = Projects.objects.get(apikey=apikey)
    except ObjectDoesNotExist:
        print 'invalid pid'
        return HttpResponse('')

    # Post 로 원하는 Date의 range를 얻어와서
    errorElements = Errors.objects.filter(
        pid=projectElement,
        lastdate__range=(week, today)).order_by('-errorweight', 'rank',
                                                '-lastdate')
    valid_tag = Tags.objects.filter(
        pid=projectElement).values('tag').distinct().order_by('tag')
    valid_class = errorElements.values('errorclassname').distinct().order_by(
        'errorclassname')

    #valid_app = Appstatistics.objects.filter(iderror__in=errorElements).values('appversion').distinct().order_by('-appversion')
    #valid_os = Osstatistics.objects.filter(iderror__in=errorElements).values('osversion').distinct().order_by('-osversion')

    valid_app = Appstatistics.objects.filter(pid=projectElement).values(
        'appversion').distinct().order_by('-appversion')
    valid_os = Osstatistics.objects.filter(pid=projectElement).values(
        'osversion').distinct().order_by('-osversion')

    # Web Rendering용 데이터 만들기
    osv_list = []
    os_idx = -1
    prev_v = ['-1', '-1', '-1']
    for e in valid_os:
        v = e['osversion'].split('.')
        if len(v) < 2:
            v.append(' ')
        if len(v) < 3:
            v.append(' ')
        if v[0] != prev_v[0] or v[1] != prev_v[1]:
            prev_v = v
            os_idx += 1
            osv_list.append({})
            osv_list[os_idx]['key'] = '%s.%s' % (v[0], v[1])
            osv_list[os_idx]['value'] = []
        osv_list[os_idx]['value'].append(e['osversion'])

    appv_list = []
    app_idx = -1
    prev_v = ['-1', '-1', '-1']
    for e in valid_app:
        v = e['appversion'].split('.')
        if len(v) < 2:
            v.append(' ')
        if len(v) < 3:
            v.append(' ')
        if v[0] != prev_v[0] or v[1] != prev_v[1]:
            prev_v = v
            app_idx += 1
            appv_list.append({})
            appv_list[app_idx]['key'] = '%s.%s' % (v[0], v[1])
            appv_list[app_idx]['value'] = []
        appv_list[app_idx]['value'].append(e['appversion'])

    tag_list = []
    for e in valid_tag:
        tag_list.append(e['tag'])

    class_list = []
    for e in valid_class:
        class_list.append(e['errorclassname'])

    osv_margin = ''
    for i in range(0, 5 - len(osv_list)):
        osv_margin += ' '

    appv_margin = ''
    for i in range(0, 5 - len(appv_list)):
        appv_margin += ' '

    user = AuthUser.objects.get(username=request.user)

    tpl = loader.get_template('filter.html')
    filterdict = {
        #'ServerURL' : 'http://'+request.get_host() + '/urqa/project/',
        'tag_list': tag_list,
        'class_list': class_list,
        'osv_list': osv_list,
        'margin': {
            'osv': osv_margin,
            'appv': appv_margin
        },
        'appv_list': appv_list,
        'max_error': errorElements.count()
    }

    userdict = getUserProfileDict(user)
    apikeydict = getApikeyDict(apikey)
    settingdict = getSettingDict(projectelement, user)

    ctxdict = dict(userdict.items() + apikeydict.items() +
                   settingdict.items() + filterdict.items())
    ctx = Context(ctxdict)

    return HttpResponse(tpl.render(ctx))
示例#8
0
def errorDetail(request, apikey, iderror):
    #에러의 상세한 페이지를 보여주는 루틴
    valid, message, user, ErrorsElement, projectelement = author_check_error_page(
        request.user, apikey, iderror)
    if not valid:
        print message
        return HttpResponseRedirect('/urqa')

    # Status New일 경우 Open으로 자동변경
    # SuperUser는 자동변경에서 예외
    if not user.is_superuser and ErrorsElement.status == Status.New:
        ErrorsElement.status = Status.Open
        ErrorsElement.save()

    #manual_Auto
    isManual = True
    if ErrorsElement.autodetermine == 1:
        isManual = False
    else:
        isManual = True

    #Error에 해당하는 Instance들을 최근 100개 가져온다.
    instanceElements = Instances.objects.filter(
        iderror=ErrorsElement).order_by('-datetime')[:100]

    #wifi
    wifi = Instances.objects.filter(iderror=ErrorsElement, wifion=1).count()
    #gps
    gps = Instances.objects.filter(iderror=ErrorsElement, gpson=1).count()
    #mobilenetwork
    mobilenetwork = Instances.objects.filter(iderror=ErrorsElement,
                                             mobileon=1).count()

    numobins = float(ErrorsElement.numofinstances)

    ###taglist###
    tagsElements = Tags.objects.filter(iderror=ErrorsElement)
    taglist = []
    for tag in tagsElements:
        taglist.append(tag.tag)

    ###callstack###
    callstackstr = ErrorsElement.callstack
    if (RANK.Native == ErrorsElement.rank):
        callstackstrlist = callstackstr.split('\n')
    else:
        callstackstrlist = callstackstr.split('\n\t')
    counter = 0
    callstacklist = []
    compile = re.compile('\(.*?:[0-9]*?\)')
    nativecompile = re.compile('\[.*?:.*?\]')

    #print '-----------------------'
    for linstr in callstackstrlist:
        tmp = {'counter': 0, 'source': '', 'value': ''}
        counter += 1
        tmp['counter'] = counter
        tmp['value'] = re.sub('\(.*?:[0-9]*?\)', '', linstr)
        #native
        tmp['value'] = re.sub('\[.*?:.*?\]', '', tmp['value'])
        #print tmp['value']

        list = compile.findall(linstr)
        nativelist = nativecompile.findall(linstr)
        source = ''

        if len(list) > 0:
            source = list[0]
        if len(nativelist) > 0:
            source = nativelist[0]

        tmp['source'] = source
        #print tmp['source']
        callstacklist.append(tmp)

    #print '-----------------------'

    ####instance#######
    instancelist = []
    instanceCount = 0
    for instance in instanceElements:
        instancetuple = {
            'datetime': "",
            'osversion': '',
            'appversion': '',
            'device': '',
            'country': '',
            'idinstance': ''
        }
        adtimezone = toTimezone(instance.datetime, projectelement.timezone)
        instancetuple['date'] = adtimezone.__format__('%Y.%m.%d')
        instancetuple['time'] = adtimezone.__format__('%H:%M:%S')
        instancetuple['osversion'] = instance.osversion
        instancetuple['appversion'] = instance.appversion
        instancetuple['device'] = instance.device
        instancetuple['country'] = instance.country
        instancetuple['idinstance'] = instance.idinstance
        instancelist.append(instancetuple)
        instanceCount = instanceCount + 1
        if instanceCount >= 100:
            break

    #projectelement = Projects.objects.get(apikey = apikey)
    #platformdata = json.loads(get_config('app_platforms'))
    #platformtxt = get_dict_value_matchin_key(platformdata,projectelement.platform)

    CommentElements = Comments.objects.filter(
        iderror=iderror).order_by('datetime')
    commentlist = []
    for comment in CommentElements:
        commenttuple = {}
        try:
            commentuser = AuthUser.objects.get(id=comment.uid.id)
        except ObjectDoesNotExist:
            continue
        adtimezone = toTimezone(comment.datetime, projectelement.timezone)
        print 'here', adtimezone, comment.datetime
        commenttuple['imagesrc'] = commentuser.image_path
        commenttuple[
            'name'] = commentuser.first_name + ' ' + commentuser.last_name
        commenttuple['comment'] = comment.comment
        commenttuple['date'] = adtimezone.__format__('%Y.%m.%d')
        commenttuple['time'] = adtimezone.__format__('%H:%M:%S')
        commenttuple['ownercomment'] = comment.uid == user and True or False
        commenttuple['id'] = comment.idcomment
        commentlist.append(commenttuple)

    #DB에서 얻어돈 데이터들을 Web에 표시할 수 있도록 Template Rendering적용
    userdict = getUserProfileDict(user)
    apikeydict = getApikeyDict(apikey)
    settingdict = getSettingDict(projectelement, user)

    adtimezone_first = toTimezone(ErrorsElement.createdate,
                                  projectelement.timezone)
    adtimezone_last = toTimezone(ErrorsElement.lastdate,
                                 projectelement.timezone)
    detaildict = {
        'iderror':
        iderror,
        'ErrorScore':
        ErrorsElement.errorweight,
        'isManual':
        isManual,
        'ErrorName':
        ErrorsElement.errorname,
        'ErrorFile':
        '(' + ErrorsElement.errorclassname + ':' + ErrorsElement.linenum + ')',
        'Errornumofinstances':
        ErrorsElement.numofinstances,
        'Errorrecur':
        ErrorsElement.recur,
        'Errorstatus':
        ErrorsElement.status,
        'Errorswifi':
        int(wifi / numobins * 100),
        'Errorsgps':
        int(gps / numobins * 100),
        'ErrorStatus':
        ErrorsElement.status + 1,
        'Errorsmobilenetwork':
        int(mobilenetwork / numobins * 100),
        'Errorsmemoryusage':
        ErrorsElement.totalmemusage / ErrorsElement.numofinstances,
        'createdate':
        adtimezone_first.__format__('%Y.%m.%d'),
        'lastdate':
        adtimezone_last.__format__('%Y.%m.%d'),
        'ErrorRankColor':
        ErrorsElement.rank == RANK.Suspense and 'Nothing'
        or RANK.rankcolor[ErrorsElement.rank],
        'isNative':
        ErrorsElement.rank == RANK.Native,
        'tag_list':
        taglist,
        'callstack':
        callstacklist,
        'instance_list':
        instancelist,
        'comment_list':
        commentlist,
        'so_file_list':
        Sofiles.objects.filter(pid=projectelement)
    }
    ctxdict = dict(userdict.items() + apikeydict.items() +
                   settingdict.items() + detaildict.items())

    tpl = loader.get_template('details.html')
    #ctx = Context(ctxdict);
    return render(request, 'details.html', ctxdict)