コード例 #1
0
ファイル: views.py プロジェクト: hajunho/URQA-Server
def receive_native(request):
    #Client Native를 받는 루틴
    print 'receive_native requested'
    try:
        jsonData = json.loads(request.body,encoding='utf-8')
        #req_dump = None
    except Exception as e:
        print >> sys.stderr, 'connect error!!!!! bad request.body'
        #print >> sys.stderr, 'request.body = ', req_dump.body
        #print >> sys.stderr, 'request = ',req_dump
        print >> sys.stderr, 'Exception = ', e
        #req_dump = None
        return HttpResponse(json.dumps({'idinstance':0}), 'application/json');
    #print jsonData

    jsonData = client_data_validate(jsonData)

    #step1: apikey를 이용하여 project찾기
    #apikey가 validate한지 확인하기.
    try:
        apikey = jsonData['apikey']
        projectElement = Projects.objects.get(apikey=apikey)
    except ObjectDoesNotExist:
        print 'Invalid apikey'
        return HttpResponse('Invalid apikey')


    #step2: dummy errorElement생성
    #새로 들어온 에러라면 새로운 에러 생성
    #if int(jsonData['rank']) == -1:
    #    autodetermine = 1 #True
    #else:
    #    autodetermine = 0 #False
    autodetermine = 0

    errorElement = Errors(
        pid = projectElement,
        errorname = 'dummy',
        errorclassname = 'native',
        linenum = 0,
        autodetermine = autodetermine,
        rank = int(jsonData['rank']), # Undesided = -1, unhandled = 0, critical = 1, major = 2, minor = 3, native = 4
        status = 0, # 0 = new, 1 = open, 2 = ignore, 3 = renew
        createdate = getUTCawaredatetime(),
        lastdate = getUTCawaredatetime(),
        numofinstances = 1,
        callstack = '',#jsonData['callstack'],
        wifion = jsonData['wifion'],
        gpson = jsonData['gpson'],
        mobileon = jsonData['mobileon'],
        totalmemusage = jsonData['appmemtotal'],
        errorweight = 10,
        recur = 0,
    )
    errorElement.save()

    #step3: 테그 저장
    tagstr = jsonData['tag']
    if tagstr:
        tagElement, created = Tags.objects.get_or_create(iderror=errorElement,pid=projectElement,tag=tagstr)
    #step4: 인스턴스 생성하기

    instanceElement = Instances(
        iderror = errorElement,
        ins_count = errorElement.numofinstances,
        sdkversion = jsonData['sdkversion'],
        appversion = jsonData['appversion'],
        osversion = jsonData['osversion'],
        kernelversion = jsonData['kernelversion'],
        appmemmax = jsonData['appmemmax'],
        appmemfree = jsonData['appmemfree'],
        appmemtotal = jsonData['appmemtotal'],
        country = jsonData['country'],
        datetime = getUTCawaredatetime(),
        locale = jsonData['locale'],
        mobileon = jsonData['mobileon'],
        gpson = jsonData['gpson'],
        wifion = jsonData['wifion'],
        device = jsonData['device'],
        rooted = jsonData['rooted'],
        scrheight = jsonData['scrheight'],
        scrwidth = jsonData['scrwidth'],
        scrorientation = jsonData['scrorientation'],
        sysmemlow = jsonData['sysmemlow'],
        log_path = '',
        batterylevel = jsonData['batterylevel'],
        availsdcard = jsonData['availsdcard'],
        xdpi = jsonData['xdpi'],
        ydpi = jsonData['ydpi'],
        lastactivity = jsonData['lastactivity'],
    )
    # primary key가 Auto-incrementing이기 때문에 save한 후 primary key를 읽을 수 있다.
    instanceElement.save()


    #step5: 이벤트패스 생성
    #print 'here! ' + instanceElement.idinstance
    #instanceElement.update()
    appversion = jsonData['appversion']

    map_path = os.path.join(PROJECT_DIR,get_config('proguard_map_path'))
    map_path = os.path.join(map_path,projectElement.apikey)
    map_path = os.path.join(map_path,appversion)

    try:
        mapElement = Proguardmap.objects.get(pid=projectElement,appversion=appversion)
    except ObjectDoesNotExist:
        mapElement = None
        print 'no proguard mapfile'



    print 'instanceElement.idinstance',instanceElement.idinstance
    eventpath = jsonData['eventpaths']

    depth = 10
    for event in reversed(eventpath):
        temp_str = event['classname'] + '.' + event['methodname']
        temp_str = proguard_retrace_oneline(temp_str,event['linenum'],map_path,mapElement)
        flag = temp_str.rfind('.')
        classname = temp_str[0:flag]
        methodname =  temp_str[flag+1:]

        if not 'label' in event:    #event path에 label적용, 기존버전과 호환성을 확보하기위해 'label'초기화를 해줌 client ver 0.91 ->
            event['label'] = ""
        Eventpaths.objects.create(
            idinstance = instanceElement,
            iderror = errorElement,
            ins_count = errorElement.numofinstances,
            datetime = naive2aware(event['datetime']),
            classname = classname,
            methodname = methodname,
            linenum = event['linenum'],
            label = event['label'],
            depth = depth,
        )
        depth -= 1
    return HttpResponse(json.dumps({'idinstance':instanceElement.idinstance}), 'application/json');
コード例 #2
0
ファイル: views.py プロジェクト: hajunho/URQA-Server
def receive_exception(request):
    #Client로부터 올라오는 exception을 수집하는 루틴
    try:
        jsonData = json.loads(request.body,encoding='utf-8')
        #req_dump = None
    except Exception as e:
        print >> sys.stderr, 'connect error!!!!! bad request.body'
        #print >> sys.stderr, 'request.body = ', req_dump.body
        #print >> sys.stderr, 'request = ',req_dump
        print >> sys.stderr, 'Exception = ', e
        #req_dump = None
        return HttpResponse(json.dumps({'idinstance':0}), 'application/json');

    #Client로부터 들어온 데이터의 무결성을 검사한다.
    jsonData = client_data_validate(jsonData)


    #step1: apikey를 이용하여 project찾기
    #apikey가 validate한지 확인하기.
    try:
        apikey = jsonData['apikey']
        projectElement = Projects.objects.get(apikey=apikey)
    except ObjectDoesNotExist:
        print 'Invalid apikey'
        return HttpResponse('Invalid apikey')

    #Exception데이터 로깅.
    print >> sys.stderr, 'receive_exception requested',apikey
    print >> sys.stderr, '=========== JsonData ========='
    print >> sys.stderr, jsonData
    print >> sys.stderr, '=============================='

    #step2: errorname, errorclassname, linenum을 이용하여 동일한 에러가 있는지 찾기
    errorname = jsonData['errorname']
    errorclassname = jsonData['errorclassname']
    linenum = jsonData['linenum']

    print >> sys.stderr, 'appver:', jsonData['appversion'], 'osver:', jsonData['osversion']
    print >> sys.stderr, '%s %s %s' % (errorname,errorclassname,linenum)

    #step2-0: Proguard 적용 확인
    appversion = jsonData['appversion']

    map_path = os.path.join(PROJECT_DIR,get_config('proguard_map_path'))
    map_path = os.path.join(map_path,projectElement.apikey)
    map_path = os.path.join(map_path,appversion)
    try:
        #Proguard가 적용된 프로젝트의 경우 Proguard Map파일을 이용하여 Parsing한다.
        mapElement = Proguardmap.objects.get(pid=projectElement,appversion=appversion)

        errorname = proguard_retrace_oneline(errorname,linenum,map_path,mapElement)
        errorclassname = proguard_retrace_oneline(errorclassname,linenum,map_path,mapElement)
        callstack = proguard_retrace_callstack(jsonData['callstack'],map_path,mapElement)
    except ObjectDoesNotExist:
        #Proguard가 적용되지 않은 프로젝트의 경우 데이터를 그대로 사용함.
        mapElement = None
        callstack = jsonData['callstack']
        print 'no proguard mapfile'

    try:
        #동일 에러가 있는지 DB로부터 얻어온다.
        #동일 에러가 없을경우 exception루틴으로 간다.

        errorElement = Errors.objects.get(pid=projectElement,errorname=errorname,errorclassname=errorclassname,linenum=linenum)

        #새로온 인스턴스 정보로 시간 갱신
        #errorElement.lastdate = naive2aware(jsonData['datetime'])
        errorElement.callstack = callstack
        errorElement.lastdate = getUTCawaredatetime()
        errorElement.numofinstances += 1
        #errorElement.totalmemusage += jsonData['appmemtotal']
        errorElement.wifion += int(jsonData['wifion'])
        errorElement.gpson += int(jsonData['gpson'])
        errorElement.mobileon += int(jsonData['mobileon'])
        errorElement.totalmemusage += int(jsonData['appmemtotal'])
        errorElement.save()

        #통계에 사용할 DB갱신
        e, created = Appstatistics.objects.get_or_create(iderror=errorElement,appversion=jsonData['appversion'],defaults={'count':1})
        if not created:
            e.count += 1
            e.save()
        e, created = Osstatistics.objects.get_or_create(iderror=errorElement,osversion=jsonData['osversion'],defaults={'count':1})
        if not created:
            e.count += 1
            e.save()
        e, created = Devicestatistics.objects.get_or_create(iderror=errorElement,devicename=jsonData['device'],defaults={'count':1})
        if not created:
            e.count += 1
            e.save()
        e, created = Countrystatistics.objects.get_or_create(iderror=errorElement,countryname=jsonData['country'],defaults={'count':1})
        if not created:
            e.count += 1
            e.save()
        e, created = Activitystatistics.objects.get_or_create(iderror=errorElement,activityname=jsonData['lastactivity'],defaults={'count':1})
        if not created:
            e.count += 1
            e.save()

    except ObjectDoesNotExist:
        #새로운 에러로 판별하여 DB 에러테이블에 데이터를 생성한다.
        autodetermine = 0 #deprecated
        errorElement = Errors(
            pid = projectElement,
            errorname = errorname,
            errorclassname = errorclassname,
            linenum = linenum,
            autodetermine = autodetermine,
            rank = int(jsonData['rank']), # Undesided = -1, unhandled = 0, critical = 1, major = 2, minor = 3, native = 4
            status = 0, # 0 = new, 1 = open, 2 = fixed, 3 = ignore
            createdate = getUTCawaredatetime(),
            lastdate = getUTCawaredatetime(),
            numofinstances = 1,
            callstack = callstack,
            wifion = jsonData['wifion'],
            gpson = jsonData['gpson'],
            mobileon = jsonData['mobileon'],
            totalmemusage = jsonData['appmemtotal'],
            errorweight = 10,
            recur = 0,
        )
        errorElement.save()
        #통계용 데이터도 생성한다.
        Appstatistics.objects.create(iderror=errorElement,appversion=jsonData['appversion'],count=1)
        Osstatistics.objects.create(iderror=errorElement,osversion=jsonData['osversion'],count=1)
        Devicestatistics.objects.create(iderror=errorElement,devicename=jsonData['device'],count=1)
        Countrystatistics.objects.create(iderror=errorElement,countryname=jsonData['country'],count=1)
        Activitystatistics.objects.create(iderror=errorElement,activityname=jsonData['lastactivity'],count=1)
        #error score 계산 에러스코어 삭제
        #calc_errorScore(errorElement)
    #step3: 테그 저장
    if jsonData['tag']:
        #테그 데이터가 있다면 테그를 생성한다.
        tagstr = jsonData['tag']
        tagElement, created = Tags.objects.get_or_create(iderror=errorElement,pid=projectElement,tag=tagstr)


    #step4: 인스턴스 생성하기
    #1개의 에러에는 여러개이 인스턴스
    instanceElement = Instances(
        iderror = errorElement,
        ins_count = errorElement.numofinstances,
        sdkversion = jsonData['sdkversion'],
        appversion = jsonData['appversion'],
        osversion = jsonData['osversion'],
        kernelversion = jsonData['kernelversion'],
        appmemmax = jsonData['appmemmax'],
        appmemfree = jsonData['appmemfree'],
        appmemtotal = jsonData['appmemtotal'],
        country = jsonData['country'],
        datetime = getUTCawaredatetime(),
        locale = jsonData['locale'],
        mobileon = jsonData['mobileon'],
        gpson = jsonData['gpson'],
        wifion = jsonData['wifion'],
        device = jsonData['device'],
        rooted = jsonData['rooted'],
        scrheight = jsonData['scrheight'],
        scrwidth = jsonData['scrwidth'],
        scrorientation = jsonData['scrorientation'],
        sysmemlow = jsonData['sysmemlow'],
        log_path = '',
        batterylevel = jsonData['batterylevel'],
        availsdcard = jsonData['availsdcard'],
        xdpi = jsonData['xdpi'],
        ydpi = jsonData['ydpi'],
        lastactivity = jsonData['lastactivity'],
        callstack = callstack,
    )
    # primary key가 Auto-incrementing이기 때문에 save한 후 primary key를 읽을 수 있다.
    instanceElement.save()


    #step5: 이벤트패스 생성
    #print 'here! ' + instanceElement.idinstance
    #instanceElement.update()
    print >> sys.stderr, 'instanceElement.idinstance',instanceElement.idinstance
    eventpath = jsonData['eventpaths']

    depth = 10
    for event in reversed(eventpath):
        temp_str = event['classname'] + '.' + event['methodname']
        temp_str = proguard_retrace_oneline(temp_str,event['linenum'],map_path,mapElement)
        flag = temp_str.rfind('.')
        classname = temp_str[0:flag]
        methodname =  temp_str[flag+1:]
        if not 'label' in event:    #event path에 label적용, 기존버전과 호환성을 확보하기위해 'label'초기화를 해줌 client ver 0.91 ->
            event['label'] = ""
        Eventpaths.objects.create(
            idinstance = instanceElement,
            iderror = errorElement,
            ins_count = errorElement.numofinstances,
            datetime = naive2aware(event['datetime']),
            classname = classname,
            methodname = methodname,
            linenum = event['linenum'],
            label = event['label'],
            depth = depth
        )
        depth -= 1

    #calc_eventpath(errorElement)
    return HttpResponse(json.dumps({'idinstance':instanceElement.idinstance}), 'application/json');
コード例 #3
0
def receive_native(request):
    #Client Native를 받는 루틴
    print 'receive_native requested'
    try:
        jsonData = json.loads(request.body, encoding='utf-8')
        #req_dump = None
    except Exception as e:
        print >> sys.stderr, 'connect error!!!!! bad request.body'
        #print >> sys.stderr, 'request.body = ', req_dump.body
        #print >> sys.stderr, 'request = ',req_dump
        print >> sys.stderr, 'Exception = ', e
        #req_dump = None
        return HttpResponse(json.dumps({'idinstance': 0}), 'application/json')
    #print jsonData

    jsonData = client_data_validate(jsonData)

    #step1: apikey를 이용하여 project찾기
    #apikey가 validate한지 확인하기.
    try:
        apikey = jsonData['apikey']
        projectElement = Projects.objects.get(apikey=apikey)
    except ObjectDoesNotExist:
        print 'Invalid apikey'
        return HttpResponse('Invalid apikey')

    #step2: dummy errorElement생성
    #새로 들어온 에러라면 새로운 에러 생성
    #if int(jsonData['rank']) == -1:
    #    autodetermine = 1 #True
    #else:
    #    autodetermine = 0 #False
    autodetermine = 0

    errorElement = Errors(
        pid=projectElement,
        errorname='dummy',
        errorclassname='native',
        linenum=0,
        autodetermine=autodetermine,
        rank=int(
            jsonData['rank']
        ),  # Undesided = -1, unhandled = 0, critical = 1, major = 2, minor = 3, native = 4
        status=0,  # 0 = new, 1 = open, 2 = ignore, 3 = renew
        createdate=getUTCawaredatetime(),
        lastdate=getUTCawaredatetime(),
        numofinstances=1,
        callstack='',  #jsonData['callstack'],
        wifion=jsonData['wifion'],
        gpson=jsonData['gpson'],
        mobileon=jsonData['mobileon'],
        totalmemusage=jsonData['appmemtotal'],
        errorweight=10,
        recur=0,
    )
    errorElement.save()

    #step3: 테그 저장
    tagstr = jsonData['tag']
    if tagstr:
        tagElement, created = Tags.objects.get_or_create(iderror=errorElement,
                                                         pid=projectElement,
                                                         tag=tagstr)
    #step4: 인스턴스 생성하기

    instanceElement = Instances(
        iderror=errorElement,
        ins_count=errorElement.numofinstances,
        sdkversion=jsonData['sdkversion'],
        appversion=jsonData['appversion'],
        osversion=jsonData['osversion'],
        kernelversion=jsonData['kernelversion'],
        appmemmax=jsonData['appmemmax'],
        appmemfree=jsonData['appmemfree'],
        appmemtotal=jsonData['appmemtotal'],
        country=jsonData['country'],
        datetime=getUTCawaredatetime(),
        locale=jsonData['locale'],
        mobileon=jsonData['mobileon'],
        gpson=jsonData['gpson'],
        wifion=jsonData['wifion'],
        device=jsonData['device'],
        rooted=jsonData['rooted'],
        scrheight=jsonData['scrheight'],
        scrwidth=jsonData['scrwidth'],
        scrorientation=jsonData['scrorientation'],
        sysmemlow=jsonData['sysmemlow'],
        log_path='',
        batterylevel=jsonData['batterylevel'],
        availsdcard=jsonData['availsdcard'],
        xdpi=jsonData['xdpi'],
        ydpi=jsonData['ydpi'],
        lastactivity=jsonData['lastactivity'],
    )
    # primary key가 Auto-incrementing이기 때문에 save한 후 primary key를 읽을 수 있다.
    instanceElement.save()

    #step5: 이벤트패스 생성
    #print 'here! ' + instanceElement.idinstance
    #instanceElement.update()
    appversion = jsonData['appversion']

    map_path = os.path.join(PROJECT_DIR, get_config('proguard_map_path'))
    map_path = os.path.join(map_path, projectElement.apikey)
    map_path = os.path.join(map_path, appversion)

    try:
        mapElement = Proguardmap.objects.get(pid=projectElement,
                                             appversion=appversion)
    except ObjectDoesNotExist:
        mapElement = None
        print 'no proguard mapfile'

    print 'instanceElement.idinstance', instanceElement.idinstance
    eventpath = jsonData['eventpaths']

    depth = 10
    for event in reversed(eventpath):
        temp_str = event['classname'] + '.' + event['methodname']
        temp_str = proguard_retrace_oneline(temp_str, event['linenum'],
                                            map_path, mapElement)
        flag = temp_str.rfind('.')
        classname = temp_str[0:flag]
        methodname = temp_str[flag + 1:]

        if not 'label' in event:  #event path에 label적용, 기존버전과 호환성을 확보하기위해 'label'초기화를 해줌 client ver 0.91 ->
            event['label'] = ""
        Eventpaths.objects.create(
            idinstance=instanceElement,
            iderror=errorElement,
            ins_count=errorElement.numofinstances,
            datetime=naive2aware(event['datetime']),
            classname=classname,
            methodname=methodname,
            linenum=event['linenum'],
            label=event['label'],
            depth=depth,
        )
        depth -= 1
    return HttpResponse(json.dumps({'idinstance': instanceElement.idinstance}),
                        'application/json')
コード例 #4
0
def receive_exception(request):
    #Client로부터 올라오는 exception을 수집하는 루틴
    try:
        jsonData = json.loads(request.body, encoding='utf-8')
        #req_dump = None
    except Exception as e:
        print >> sys.stderr, 'connect error!!!!! bad request.body'
        #print >> sys.stderr, 'request.body = ', req_dump.body
        #print >> sys.stderr, 'request = ',req_dump
        print >> sys.stderr, 'Exception = ', e
        #req_dump = None
        return HttpResponse(json.dumps({'idinstance': 0}), 'application/json')

    #Client로부터 들어온 데이터의 무결성을 검사한다.
    jsonData = client_data_validate(jsonData)

    #step1: apikey를 이용하여 project찾기
    #apikey가 validate한지 확인하기.
    try:
        apikey = jsonData['apikey']
        projectElement = Projects.objects.get(apikey=apikey)
    except ObjectDoesNotExist:
        print 'Invalid apikey'
        return HttpResponse('Invalid apikey')

    #Exception데이터 로깅.
    print >> sys.stderr, 'receive_exception requested', apikey
    print >> sys.stderr, '=========== JsonData ========='
    print >> sys.stderr, jsonData
    print >> sys.stderr, '=============================='

    #step2: errorname, errorclassname, linenum을 이용하여 동일한 에러가 있는지 찾기
    errorname = jsonData['errorname']
    errorclassname = jsonData['errorclassname']
    linenum = jsonData['linenum']

    print >> sys.stderr, 'appver:', jsonData['appversion'], 'osver:', jsonData[
        'osversion']
    print >> sys.stderr, '%s %s %s' % (errorname, errorclassname, linenum)

    #step2-0: Proguard 적용 확인
    appversion = jsonData['appversion']

    map_path = os.path.join(PROJECT_DIR, get_config('proguard_map_path'))
    map_path = os.path.join(map_path, projectElement.apikey)
    map_path = os.path.join(map_path, appversion)
    try:
        #Proguard가 적용된 프로젝트의 경우 Proguard Map파일을 이용하여 Parsing한다.
        mapElement = Proguardmap.objects.get(pid=projectElement,
                                             appversion=appversion)

        errorname = proguard_retrace_oneline(errorname, linenum, map_path,
                                             mapElement)
        errorclassname = proguard_retrace_oneline(errorclassname, linenum,
                                                  map_path, mapElement)
        callstack = proguard_retrace_callstack(jsonData['callstack'], map_path,
                                               mapElement)
    except ObjectDoesNotExist:
        #Proguard가 적용되지 않은 프로젝트의 경우 데이터를 그대로 사용함.
        mapElement = None
        callstack = jsonData['callstack']
        print 'no proguard mapfile'

    try:
        #동일 에러가 있는지 DB로부터 얻어온다.
        #동일 에러가 없을경우 exception루틴으로 간다.

        errorElement = Errors.objects.get(pid=projectElement,
                                          errorname=errorname,
                                          errorclassname=errorclassname,
                                          linenum=linenum)

        #새로온 인스턴스 정보로 시간 갱신
        #errorElement.lastdate = naive2aware(jsonData['datetime'])
        errorElement.callstack = callstack
        errorElement.lastdate = getUTCawaredatetime()
        errorElement.numofinstances += 1
        #errorElement.totalmemusage += jsonData['appmemtotal']
        errorElement.wifion += int(jsonData['wifion'])
        errorElement.gpson += int(jsonData['gpson'])
        errorElement.mobileon += int(jsonData['mobileon'])
        errorElement.totalmemusage += int(jsonData['appmemtotal'])
        errorElement.save()

        #통계에 사용할 DB갱신
        e, created = Appstatistics.objects.get_or_create(
            iderror=errorElement,
            appversion=jsonData['appversion'],
            defaults={'count': 1})
        if not created:
            e.count += 1
            e.save()
        e, created = Osstatistics.objects.get_or_create(
            iderror=errorElement,
            osversion=jsonData['osversion'],
            defaults={'count': 1})
        if not created:
            e.count += 1
            e.save()
        e, created = Devicestatistics.objects.get_or_create(
            iderror=errorElement,
            devicename=jsonData['device'],
            defaults={'count': 1})
        if not created:
            e.count += 1
            e.save()
        e, created = Countrystatistics.objects.get_or_create(
            iderror=errorElement,
            countryname=jsonData['country'],
            defaults={'count': 1})
        if not created:
            e.count += 1
            e.save()
        e, created = Activitystatistics.objects.get_or_create(
            iderror=errorElement,
            activityname=jsonData['lastactivity'],
            defaults={'count': 1})
        if not created:
            e.count += 1
            e.save()

    except ObjectDoesNotExist:
        #새로운 에러로 판별하여 DB 에러테이블에 데이터를 생성한다.
        autodetermine = 0  #deprecated
        errorElement = Errors(
            pid=projectElement,
            errorname=errorname,
            errorclassname=errorclassname,
            linenum=linenum,
            autodetermine=autodetermine,
            rank=int(
                jsonData['rank']
            ),  # Undesided = -1, unhandled = 0, critical = 1, major = 2, minor = 3, native = 4
            status=0,  # 0 = new, 1 = open, 2 = fixed, 3 = ignore
            createdate=getUTCawaredatetime(),
            lastdate=getUTCawaredatetime(),
            numofinstances=1,
            callstack=callstack,
            wifion=jsonData['wifion'],
            gpson=jsonData['gpson'],
            mobileon=jsonData['mobileon'],
            totalmemusage=jsonData['appmemtotal'],
            errorweight=10,
            recur=0,
        )
        errorElement.save()
        #통계용 데이터도 생성한다.
        Appstatistics.objects.create(iderror=errorElement,
                                     appversion=jsonData['appversion'],
                                     count=1)
        Osstatistics.objects.create(iderror=errorElement,
                                    osversion=jsonData['osversion'],
                                    count=1)
        Devicestatistics.objects.create(iderror=errorElement,
                                        devicename=jsonData['device'],
                                        count=1)
        Countrystatistics.objects.create(iderror=errorElement,
                                         countryname=jsonData['country'],
                                         count=1)
        Activitystatistics.objects.create(
            iderror=errorElement,
            activityname=jsonData['lastactivity'],
            count=1)
        #error score 계산 에러스코어 삭제
        #calc_errorScore(errorElement)
    #step3: 테그 저장
    if jsonData['tag']:
        #테그 데이터가 있다면 테그를 생성한다.
        tagstr = jsonData['tag']
        tagElement, created = Tags.objects.get_or_create(iderror=errorElement,
                                                         pid=projectElement,
                                                         tag=tagstr)

    #step4: 인스턴스 생성하기
    #1개의 에러에는 여러개이 인스턴스
    instanceElement = Instances(
        iderror=errorElement,
        ins_count=errorElement.numofinstances,
        sdkversion=jsonData['sdkversion'],
        appversion=jsonData['appversion'],
        osversion=jsonData['osversion'],
        kernelversion=jsonData['kernelversion'],
        appmemmax=jsonData['appmemmax'],
        appmemfree=jsonData['appmemfree'],
        appmemtotal=jsonData['appmemtotal'],
        country=jsonData['country'],
        datetime=getUTCawaredatetime(),
        locale=jsonData['locale'],
        mobileon=jsonData['mobileon'],
        gpson=jsonData['gpson'],
        wifion=jsonData['wifion'],
        device=jsonData['device'],
        rooted=jsonData['rooted'],
        scrheight=jsonData['scrheight'],
        scrwidth=jsonData['scrwidth'],
        scrorientation=jsonData['scrorientation'],
        sysmemlow=jsonData['sysmemlow'],
        log_path='',
        batterylevel=jsonData['batterylevel'],
        availsdcard=jsonData['availsdcard'],
        xdpi=jsonData['xdpi'],
        ydpi=jsonData['ydpi'],
        lastactivity=jsonData['lastactivity'],
        callstack=callstack,
    )
    # primary key가 Auto-incrementing이기 때문에 save한 후 primary key를 읽을 수 있다.
    instanceElement.save()

    #step5: 이벤트패스 생성
    #print 'here! ' + instanceElement.idinstance
    #instanceElement.update()
    print >> sys.stderr, 'instanceElement.idinstance', instanceElement.idinstance
    eventpath = jsonData['eventpaths']

    depth = 10
    for event in reversed(eventpath):
        temp_str = event['classname'] + '.' + event['methodname']
        temp_str = proguard_retrace_oneline(temp_str, event['linenum'],
                                            map_path, mapElement)
        flag = temp_str.rfind('.')
        classname = temp_str[0:flag]
        methodname = temp_str[flag + 1:]
        if not 'label' in event:  #event path에 label적용, 기존버전과 호환성을 확보하기위해 'label'초기화를 해줌 client ver 0.91 ->
            event['label'] = ""
        Eventpaths.objects.create(idinstance=instanceElement,
                                  iderror=errorElement,
                                  ins_count=errorElement.numofinstances,
                                  datetime=naive2aware(event['datetime']),
                                  classname=classname,
                                  methodname=methodname,
                                  linenum=event['linenum'],
                                  label=event['label'],
                                  depth=depth)
        depth -= 1

    #calc_eventpath(errorElement)
    return HttpResponse(json.dumps({'idinstance': instanceElement.idinstance}),
                        'application/json')
コード例 #5
0
ファイル: views.py プロジェクト: wolfses/URQA-Server
def receive_exception(request):
    jsonData = json.loads(request.body, encoding='utf-8')

    print 'receive_exception requested'
    #step1: apikey를 이용하여 project찾기
    #apikey가 validate한지 확인하기.
    try:
        apikey = jsonData['apikey']
        projectElement = Projects.objects.get(apikey=apikey)
    except ObjectDoesNotExist:
        print 'Invalid apikey'
        return HttpResponse('Invalid apikey')

    #step2: errorname, errorclassname, linenum을 이용하여 동일한 에러가 있는지 찾기
    errorname = jsonData['errorname']
    errorclassname = jsonData['errorclassname']
    linenum = jsonData['linenum']

    print '%s %s %s' % (errorname, errorclassname, linenum)

    try:
        errorElement = Errors.objects.get(pid=projectElement,
                                          errorname=errorname,
                                          errorclassname=errorclassname,
                                          linenum=linenum)
        #새로온 인스턴스 정보로 시간 갱신

        errorElement.lastdate = naive2aware(jsonData['datetime'])
        errorElement.numofinstances += 1
        errorElement.totalmemusage += jsonData['appmemtotal']
        errorElement.wifion += int(jsonData['wifion'])
        errorElement.gpson += int(jsonData['gpson'])
        errorElement.mobileon += int(jsonData['mobileon'])
        errorElement.totalmemusage += int(jsonData['appmemtotal'])
        errorElement.save()

        e, created = Appstatistics.objects.get_or_create(
            iderror=errorElement,
            appversion=jsonData['appversion'],
            defaults={'count': 1})
        if not created:
            e.count += 1
            e.save()
        e, created = Osstatistics.objects.get_or_create(
            iderror=errorElement,
            osversion=jsonData['osversion'],
            defaults={'count': 1})
        if not created:
            e.count += 1
            e.save()
        e, created = Devicestatistics.objects.get_or_create(
            iderror=errorElement,
            devicename=jsonData['device'],
            defaults={'count': 1})
        if not created:
            e.count += 1
            e.save()
        e, created = Countrystatistics.objects.get_or_create(
            iderror=errorElement,
            countryname=jsonData['country'],
            defaults={'count': 1})
        if not created:
            e.count += 1
            e.save()
        e, created = Activitystatistics.objects.get_or_create(
            iderror=errorElement,
            activityname=jsonData['lastactivity'],
            defaults={'count': 1})
        if not created:
            e.count += 1
            e.save()

        #에러 스코어 계산
        calc_errorScore(errorElement)

    except ObjectDoesNotExist:
        #새로 들어온 에러라면 새로운 에러 생성
        if int(jsonData['rank']) == -1:
            autodetermine = 1  #True
        else:
            autodetermine = 0  #False

        errorElement = Errors(
            pid=projectElement,
            errorname=errorname,
            errorclassname=errorclassname,
            linenum=linenum,
            autodetermine=autodetermine,
            rank=int(
                jsonData['rank']
            ),  # Undesided = -1, unhandled = 0, critical = 1, major = 2, minor = 3, native = 4
            status=0,  # 0 = new, 1 = open, 2 = fixed, 3 = ignore
            createdate=naive2aware(jsonData['datetime']),
            lastdate=naive2aware(jsonData['datetime']),
            numofinstances=1,
            callstack=jsonData['callstack'],
            wifion=jsonData['wifion'],
            gpson=jsonData['gpson'],
            mobileon=jsonData['mobileon'],
            totalmemusage=jsonData['appmemtotal'],
            errorweight=10,
            recur=0,
        )
        errorElement.save()
        Appstatistics.objects.create(iderror=errorElement,
                                     appversion=jsonData['appversion'],
                                     count=1)
        Osstatistics.objects.create(iderror=errorElement,
                                    osversion=jsonData['osversion'],
                                    count=1)
        Devicestatistics.objects.create(iderror=errorElement,
                                        devicename=jsonData['device'],
                                        count=1)
        Countrystatistics.objects.create(iderror=errorElement,
                                         countryname=jsonData['country'],
                                         count=1)
        Activitystatistics.objects.create(
            iderror=errorElement,
            activityname=jsonData['lastactivity'],
            count=1)
        #error score 계산
        calc_errorScore(errorElement)
    #step3: 테그 저장
    if jsonData['tag']:
        tagstr = jsonData['tag']
        tagElement, created = Tags.objects.get_or_create(iderror=errorElement,
                                                         pid=projectElement,
                                                         tag=tagstr)

    #step4: 인스턴스 생성하기

    instanceElement = Instances(
        iderror=errorElement,
        ins_count=errorElement.numofinstances,
        sdkversion=jsonData['sdkversion'],
        appversion=jsonData['appversion'],
        osversion=jsonData['osversion'],
        kernelversion=jsonData['kernelversion'],
        appmemmax=jsonData['appmemmax'],
        appmemfree=jsonData['appmemfree'],
        appmemtotal=jsonData['appmemtotal'],
        country=jsonData['country'],
        datetime=naive2aware(jsonData['datetime']),
        locale=jsonData['locale'],
        mobileon=jsonData['mobileon'],
        gpson=jsonData['gpson'],
        wifion=jsonData['wifion'],
        device=jsonData['device'],
        rooted=jsonData['rooted'],
        scrheight=jsonData['scrheight'],
        scrwidth=jsonData['scrwidth'],
        scrorientation=jsonData['scrorientation'],
        sysmemlow=jsonData['sysmemlow'],
        log_path='',
        batterylevel=jsonData['batterylevel'],
        availsdcard=jsonData['availsdcard'],
        xdpi=jsonData['xdpi'],
        ydpi=jsonData['ydpi'],
        lastactivity=jsonData['lastactivity'],
    )
    # primary key가 Auto-incrementing이기 때문에 save한 후 primary key를 읽을 수 있다.
    instanceElement.save()

    #step5: 이벤트패스 생성
    #print 'here! ' + instanceElement.idinstance
    #instanceElement.update()
    print instanceElement.idinstance
    eventpath = jsonData['eventpaths']

    #테스트때문에 잠시 안씀
    depth = 10
    for event in reversed(eventpath):
        Eventpaths.objects.create(idinstance=instanceElement,
                                  iderror=errorElement,
                                  ins_count=errorElement.numofinstances,
                                  datetime=naive2aware(event['datetime']),
                                  classname=event['classname'],
                                  methodname=event['methodname'],
                                  linenum=event['linenum'],
                                  depth=depth)
        depth -= 1

    #calc_eventpath(errorElement)
    return HttpResponse(json.dumps({'idinstance': instanceElement.idinstance}),
                        'application/json')
コード例 #6
0
ファイル: views.py プロジェクト: wolfses/URQA-Server
def receive_native(request):
    print 'receive_native requested'
    #print request.body
    jsonData = json.loads(request.body, encoding='utf-8')
    #print jsonData

    #step1: apikey를 이용하여 project찾기
    #apikey가 validate한지 확인하기.
    try:
        apikey = jsonData['apikey']
        projectElement = Projects.objects.get(apikey=apikey)
    except ObjectDoesNotExist:
        print 'Invalid apikey'
        return HttpResponse('Invalid apikey')

    #step2: dummy errorElement생성

    #새로 들어온 에러라면 새로운 에러 생성
    if int(jsonData['rank']) == -1:
        autodetermine = 1  #True
    else:
        autodetermine = 0  #False

    errorElement = Errors(
        pid=projectElement,
        errorname='dummy',
        errorclassname='native',
        linenum=0,
        autodetermine=autodetermine,
        rank=int(
            jsonData['rank']
        ),  # Undesided = -1, unhandled = 0, critical = 1, major = 2, minor = 3, native = 4
        status=0,  # 0 = new, 1 = open, 2 = ignore, 3 = renew
        createdate=naive2aware(jsonData['datetime']),
        lastdate=naive2aware(jsonData['datetime']),
        numofinstances=1,
        callstack='',  #jsonData['callstack'],
        wifion=jsonData['wifion'],
        gpson=jsonData['gpson'],
        mobileon=jsonData['mobileon'],
        totalmemusage=jsonData['appmemtotal'],
        errorweight=10,
        recur=0,
    )
    errorElement.save()

    #step3: 테그 저장
    tagstr = jsonData['tag']
    if tagstr:
        tagElement, created = Tags.objects.get_or_create(iderror=errorElement,
                                                         pid=projectElement,
                                                         tag=tagstr)
    #step4: 인스턴스 생성하기

    instanceElement = Instances(
        iderror=errorElement,
        ins_count=errorElement.numofinstances,
        sdkversion=jsonData['sdkversion'],
        appversion=jsonData['appversion'],
        osversion=jsonData['osversion'],
        kernelversion=jsonData['kernelversion'],
        appmemmax=jsonData['appmemmax'],
        appmemfree=jsonData['appmemfree'],
        appmemtotal=jsonData['appmemtotal'],
        country=jsonData['country'],
        datetime=naive2aware(jsonData['datetime']),
        locale=jsonData['locale'],
        mobileon=jsonData['mobileon'],
        gpson=jsonData['gpson'],
        wifion=jsonData['wifion'],
        device=jsonData['device'],
        rooted=jsonData['rooted'],
        scrheight=jsonData['scrheight'],
        scrwidth=jsonData['scrwidth'],
        scrorientation=jsonData['scrorientation'],
        sysmemlow=jsonData['sysmemlow'],
        log_path='',
        batterylevel=jsonData['batterylevel'],
        availsdcard=jsonData['availsdcard'],
        xdpi=jsonData['xdpi'],
        ydpi=jsonData['ydpi'],
        lastactivity=jsonData['lastactivity'],
    )
    # primary key가 Auto-incrementing이기 때문에 save한 후 primary key를 읽을 수 있다.
    instanceElement.save()

    #step5: 이벤트패스 생성
    #print 'here! ' + instanceElement.idinstance
    #instanceElement.update()
    print instanceElement.idinstance
    eventpath = jsonData['eventpaths']

    depth = 10
    for event in reversed(eventpath):
        Eventpaths.objects.create(
            idinstance=instanceElement,
            iderror=errorElement,
            ins_count=errorElement.numofinstances,
            datetime=naive2aware(event['datetime']),
            classname=event['classname'],
            methodname=event['methodname'],
            linenum=event['linenum'],
            depth=depth,
        )
        depth -= 1
    return HttpResponse(json.dumps({'idinstance': instanceElement.idinstance}),
                        'application/json')