Beispiel #1
0
    def post(self):
        api_key = self.get_argument('apiKey')
        app_db = account.get_db_for_api_key(api_key)
        if app_db is None:
            raise HTTPError(400, 'Invalid API Key')


#        app = self.get_argument('appName')
        version = self.get_argument('version')
        try:
            version_code = int(self.get_argument('versionCode', -1))
        except ValueError as e:
            version_code = -1

        now = datetime.datetime.utcnow()
        try:
            crashtime = datetime.datetime.utcfromtimestamp(
                int(self.get_argument('crashtime', None)) / 1000.0)
        except (ValueError, TypeError):
            crashtime = now

        try:
            uploadtime = datetime.datetime.utcfromtimestamp(
                int(self.get_argument('uploadtime', None)) / 1000.0)
        except (ValueError, TypeError):
            uploadtime = now

        try:
            extras_string = self.get_argument('extras', '{}')
            extras = json.loads(extras_string)
        except (ValueError, TypeError):
            extras_string = '{}'
            extras = {}

        # adjust crash time
        crashtime = now - (uploadtime - crashtime)

        f = self.request.files.get('minidump', None)
        if f is None or len(f) == 0:
            raise HTTPError(400, 'No file found')
        filename = f[0]['filename']

        save_minidump(app_db, filename, f[0]['body'])

        conn = crashes_db.connect()
        conn.execute("SET search_path TO %s", (app_db, ))
        conn.execute(crashes.insert(),
                     version=version,
                     version_code=version_code,
                     crash=filename,
                     crashtime=crashtime,
                     extras=extras_string,
                     uploadtime=now)
        conn.execute("SET search_path TO 'public'")
        conn.close()

        breakpad_decode.delay(filename, app_db, version)
        self.write(filename)
        return
Beispiel #2
0
 def post(self, build_version=''):
     api_key = self.get_argument('api_key')
     build_version = self.get_argument('version', build_version)
     app_db = account.get_db_for_api_key(api_key)
     if app_db == None:
         raise HTTPError(403, 'Invalid API Key')
     result = save_lib(app_db, self.request.body, build_version)
     self.write(str(result))
     return
 def post(self, build_version=""):
     api_key = self.get_argument("api_key")
     build_version = self.get_argument("version", build_version)
     app_db = account.get_db_for_api_key(api_key)
     if app_db == None:
         raise HTTPError(403, "Invalid API Key")
     result = save_lib(app_db, self.request.body, build_version)
     self.write(str(result))
     return
    def post(self):
        api_key = self.get_argument("apiKey")
        app_db = account.get_db_for_api_key(api_key)
        if app_db is None:
            raise HTTPError(400, "Invalid API Key")
        #        app = self.get_argument('appName')
        version = self.get_argument("version")
        try:
            version_code = int(self.get_argument("versionCode", -1))
        except ValueError as e:
            version_code = -1

        now = datetime.datetime.utcnow()
        try:
            crashtime = datetime.datetime.utcfromtimestamp(int(self.get_argument("crashtime", None)) / 1000.0)
        except (ValueError, TypeError):
            crashtime = now

        try:
            uploadtime = datetime.datetime.utcfromtimestamp(int(self.get_argument("uploadtime", None)) / 1000.0)
        except (ValueError, TypeError):
            uploadtime = now

        try:
            extras_string = self.get_argument("extras", "{}")
            extras = json.loads(extras_string)
        except (ValueError, TypeError):
            extras_string = "{}"
            extras = {}

        # adjust crash time
        crashtime = now - (uploadtime - crashtime)

        f = self.request.files.get("minidump", None)
        if f is None or len(f) == 0:
            raise HTTPError(400, "No file found")
        filename = f[0]["filename"]

        save_minidump(app_db, filename, f[0]["body"])

        conn = crashes_db.connect()
        conn.execute("SET search_path TO %s", (app_db,))
        conn.execute(
            crashes.insert(),
            version=version,
            version_code=version_code,
            crash=filename,
            crashtime=crashtime,
            extras=extras_string,
            uploadtime=now,
        )
        conn.execute("SET search_path TO 'public'")
        conn.close()

        breakpad_decode.delay(filename, app_db, version)
        self.write(filename)
        return
Beispiel #5
0
    def get(self, basicauth_user, basicauth_pass):
        app_db = account.get_db_for_api_key(basicauth_user)
        if app_db is None:
            raise HTTPError(403, 'Invalid API Key')
        app = account.get_app_for_api_key(basicauth_user)
        app_id = app.get('app_id', None)
        secret_key = app.get('secret_key', None)
        if secret_key is None or secret_key != basicauth_pass:
            raise HTTPError(403, 'Invalid API/Secret Key combination')

        try:
            after = int(self.get_argument('after')) / 1000.0
        except ValueError:
            raise HTTPError(400, 'Invalid argument after')
        try:
            limit = int(self.get_argument('n', 1000))
        except:
            limit = 1000

        with crashes_db.connect() as conn:
            metadata = MetaData()
            table = crashes.tometadata(metadata, schema=app_db)
            result = conn.execute(
                select([
                    table.c.id, table.c.crash, table.c.crashtime,
                    table.c.uploadtime, table.c.version, table.c.version_code,
                    table.c.crash_reason, table.c.crash_address,
                    table.c.crash_line, table.c.extras,
                    table.c.crashed_thread_stacktrace
                ]).where(table.c.uploadtime >= text(
                    'to_timestamp(:after)',
                    bindparams=[bindparam('after', after)])).order_by(
                        table.c.uploadtime).limit(limit))
            fetched_crashes = []
            for row in result:
                fetched_crashes.append(
                    self.convert_crash(
                        app_id, row[table.c.id], row[table.c.crash],
                        row[table.c.crashtime], row[table.c.uploadtime],
                        row[table.c.version], row[table.c.version_code],
                        row[table.c.crash_reason], row[table.c.crash_address],
                        row[table.c.crash_line], row[table.c.extras],
                        row[table.c.crashed_thread_stacktrace]))
            self.write(json.dumps(fetched_crashes))
    def post(self):
        api_key = self.get_argument("api_key")
        crash_id = self.get_argument("crash")
        app_db = account.get_db_for_api_key(api_key)
        if app_db is None:
            raise HTTPError(403, "Invalid API Key")

        conn = crashes_db.connect()
        conn.execute("SET search_path TO %s", (app_db,))
        result = conn.execute(select([crashes.c.version, crashes.c.version_code], crashes.c.crash == crash_id))
        row = result.fetchone()
        conn.execute("SET search_path TO 'public'")
        conn.close()
        if row is None:
            raise HTTPError(404)
        version = row[0]
        breakpad_decode.delay(crash_id, app_db, version)
        self.write("0")
        return
Beispiel #7
0
    def post(self):
        api_key = self.get_argument('api_key')
        crash_id = self.get_argument('crash')
        app_db = account.get_db_for_api_key(api_key)
        if app_db is None:
            raise HTTPError(403, 'Invalid API Key')

        conn = crashes_db.connect()
        conn.execute("SET search_path TO %s", (app_db, ))
        result = conn.execute(
            select([crashes.c.version, crashes.c.version_code],
                   crashes.c.crash == crash_id))
        row = result.fetchone()
        conn.execute("SET search_path TO 'public'")
        conn.close()
        if row is None:
            raise HTTPError(404)
        version = row[0]
        breakpad_decode.delay(crash_id, app_db, version)
        self.write('0')
        return
    def get(self, basicauth_user, basicauth_pass):
        app_db = account.get_db_for_api_key(basicauth_user)
        if app_db is None:
            raise HTTPError(403, "Invalid API Key")
        app = account.get_app_for_api_key(basicauth_user)
        app_id = app.get("app_id", None)
        secret_key = app.get("secret_key", None)
        if secret_key is None or secret_key != basicauth_pass:
            raise HTTPError(403, "Invalid API/Secret Key combination")

        try:
            after = int(self.get_argument("after")) / 1000.0
        except ValueError:
            raise HTTPError(400, "Invalid argument after")
        try:
            limit = int(self.get_argument("n", 1000))
        except:
            limit = 1000

        with crashes_db.connect() as conn:
            metadata = MetaData()
            table = crashes.tometadata(metadata, schema=app_db)
            result = conn.execute(
                select(
                    [
                        table.c.id,
                        table.c.crash,
                        table.c.crashtime,
                        table.c.uploadtime,
                        table.c.version,
                        table.c.version_code,
                        table.c.crash_reason,
                        table.c.crash_address,
                        table.c.crash_line,
                        table.c.extras,
                        table.c.crashed_thread_stacktrace,
                    ]
                )
                .where(table.c.uploadtime >= text("to_timestamp(:after)", bindparams=[bindparam("after", after)]))
                .order_by(table.c.uploadtime)
                .limit(limit)
            )
            fetched_crashes = []
            for row in result:
                fetched_crashes.append(
                    self.convert_crash(
                        app_id,
                        row[table.c.id],
                        row[table.c.crash],
                        row[table.c.crashtime],
                        row[table.c.uploadtime],
                        row[table.c.version],
                        row[table.c.version_code],
                        row[table.c.crash_reason],
                        row[table.c.crash_address],
                        row[table.c.crash_line],
                        row[table.c.extras],
                        row[table.c.crashed_thread_stacktrace],
                    )
                )
            self.write(json.dumps(fetched_crashes))