示例#1
0
def index(request):

    if (request.method == "PUT" or request.method == "POST"):
        #log.log(logging.DEBUG, "got put "+ str(request.body) )
        json_data = json.loads(request.body)
        description = ""
        if (json_data.has_key("description")):
            description = json_data["description"]

        DEBUG = json_data['APP_VERSION_CODE'] == 10509999
        if DEBUG:
            log.log(logging.DEBUG,
                    "REQUEST:: %s" % json_data['APP_VERSION_CODE'])

        notallow = ["description", "solved", SESSION_NAME]
        crashreport = CrashReport()
        for key in json_data.keys():
            #if (DEBUG):
            #	log.log(logging.DEBUG, "Key: %s in POST" % (key) )
            if (not key.lower() in notallow):
                if (getattr(crashreport, key.lower(), None) != None):
                    #if(DEBUG):
                    #	log.log(logging.DEBUG, "ADDING %s -> %s" % (key.lower(),json_data[key]) )
                    v = getattr(crashreport, key.lower(), None)
                    if (v != None):
                        setattr(crashreport, key.lower(), json_data[key])
        crashreport.save()

    return HttpResponse(json.dumps({"ok": "true"}),
                        content_type="application/json")
示例#2
0
文件: views.py 项目: wrestrtdr/grm
def error(request):
    if request.method == "POST":
        data = json.loads(request.body)
        try:
            if CrashReport.objects.filter(summary=data["summary"]):
                return JsonResponse({
                    'message':
                    'Your crash report has already been submitted.'
                    ' Developers will take care of it as soon as possible.'
                })
            c = CrashReport(summary=data["summary"],
                            trace=data["trace"],
                            version=data["version"],
                            arch=data["arch"],
                            report=data["report"])
            c.save()
            return JsonResponse(
                {'message': 'Your crash report was submitted successfully.'})
        except:
            return JsonResponse(
                {
                    'message':
                    'An unspecified server error occurred and your '
                    'crash report couldn\'t be submitted. Please submit manually '
                    'to the developers!'
                },
                status='500')
    return JsonResponse({})
示例#3
0
    def parse_crash_report(self, request):
        # Get or create the parent report group for this crash report
        package_name = request.get('PACKAGE_NAME')
        report_group = CrashReportGroup.get_group(package_name)

        # Create a new crash report
        report = CrashReport(parent=report_group.key)

        # Parse POST body
        report.package_name = package_name
        report.android_version = request.get('ANDROID_VERSION')
        report.app_version_code = request.get('APP_VERSION_CODE')
        report.app_version_name = request.get('APP_VERSION_NAME')
        report.available_mem_size = request.get('AVAILABLE_MEM_SIZE')
        report.brand = request.get('BRAND')
        report.build = request.get('BUILD')
        report.crash_configuration = request.get('CRASH_CONFIGURATION')
        report.device_features = request.get('DEVICE_FEATURES')
        report.display = request.get('DISPLAY')
        report.environment = request.get('ENVIRONMENT')
        report.file_path = request.get('FILE_PATH')
        report.initial_configuration = request.get('INITIAL_CONFIGURATION')
        report.installation_id = request.get('INSTALLATION_ID')
        report.model = request.get('PHONE_MODEL')
        report.product = request.get('PRODUCT')
        report.report_id = request.get('REPORT_ID')
        report.settings_secure = request.get('SETTINGS_SECURE')
        report.settings_system = request.get('SETTINGS_SYSTEM')
        report.shared_preferences = request.get('SHARED_PREFERENCES')
        report.total_mem_size = request.get('TOTAL_MEM_SIZE')

        # Coerce date strings into parseable format
        start_date = dateparser.parse(request.get('USER_APP_START_DATE'),
                                      ignoretz=True)
        crash_date = dateparser.parse(request.get('USER_CRASH_DATE'),
                                      ignoretz=True)
        report.user_app_start_date = start_date
        report.user_crash_date = crash_date

        # If this crash report's timestamp is more recent than its parent's
        # latest crash date, update the parent group
        if report_group.latest_crash_date == None or report.user_crash_date > report_group.latest_crash_date:
            report_group.latest_crash_date = report.user_crash_date
            report_group.put()

        # Parse stack trace / summary
        stack_trace = request.get('STACK_TRACE')
        report.stack_trace = stack_trace
        summary = self.get_stack_summary(stack_trace, report.package_name)
        report.stack_summary = summary[:500]

        return report