Skip to content

Commit

Permalink
Finally hawk-python-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
n0str committed Dec 22, 2024
1 parent 26d1a8a commit c2e0d67
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 35 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ If you want to connect specific frameworks see [Flask integration](./docs/flask.

### Install module

Install `hawk-catcher` from PyPI.
Install `hawk-python-sdk` from PyPI.

```shell
$ pip install hawk-catcher
$ pip install hawk-python-sdk
```

Import Catcher module to your project.

```python
from hawk_catcher import Hawk
from hawk_python_sdk import Hawk
```

Then enable Hawk Catcher with your token and domain.
Expand Down Expand Up @@ -115,6 +115,6 @@ Repository: <https://github.com/codex-team/hawk.python>

Report a bug: <https://github.com/codex-team/hawk.python/issues>

PyPI Package: <https://pypi.python.org/pypi/hawk-catcher>
PyPI Package: <https://pypi.python.org/pypi/hawk-python-sdk>

CodeX Team: <https://codex.so/>
4 changes: 2 additions & 2 deletions docs/fastapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ This extension adds support for the [FastAPI](https://fastapi.tiangolo.com/) web
## Installation

```bash
pip install hawk-catcher[fastapi]
pip install hawk-python-sdk[fastapi]
```

import Catcher module to your project.

```python
from hawk_catcher.modules.fastapi import HawkFastapi
from hawk_python_sdk.modules.fastapi import HawkFastapi
```

```python
Expand Down
4 changes: 2 additions & 2 deletions docs/flask.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ This extension adds support for the [Flask](http://flask.pocoo.org/) web framewo
## Installation

```bash
pip install hawk-catcher[flask]
pip install hawk-python-sdk[flask]
```

import Catcher module to your project.

```python
from hawk_catcher.modules.flask import HawkFlask
from hawk_python_sdk.modules.flask import HawkFlask
```

```python
Expand Down
2 changes: 1 addition & 1 deletion example/example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from hawk_catcher import Hawk
from hawk_python_sdk import Hawk
from dotenv import load_dotenv

load_dotenv() # take environment variables from .env.
Expand Down
10 changes: 5 additions & 5 deletions example/example2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import hawk_catcher
import hawk_python_sdk
import os
from dotenv import load_dotenv

Expand All @@ -18,13 +18,13 @@ def test_method(self):
self.divide_by_zero()

def mannual_sending(self):
hawk_catcher.send(ValueError("lol"), {"ping": "pong", "number": 1})
hawk_python_sdk.send(ValueError("lol"), {"ping": "pong", "number": 1})

def send_custom_error(self):
raise InvalidToken()

def send_with_user(self):
hawk_catcher.send(
hawk_python_sdk.send(
ValueError("USER"),
None,
{'id': 1, 'name': 'Alice'}
Expand All @@ -35,9 +35,9 @@ def main():
token = os.getenv('HAWK_TOKEN')

if token is None or token == "":
print('hawk-catcher token not provided. Please provide HAWK_TOKEN variable in .env file')
print('hawk-python-sdk token not provided. Please provide HAWK_TOKEN variable in .env file')
return
hawk_catcher.init(token)
hawk_python_sdk.init(token)
test = Module()
test.mannual_sending()
test.send_with_user()
Expand Down
8 changes: 4 additions & 4 deletions example/fill_events.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import random
import os
import hawk_catcher
import hawk_python_sdk
from faker import Faker

fake = Faker()
Expand Down Expand Up @@ -48,7 +48,7 @@ def random_exception():
]

token = os.getenv('HAWK_TOKEN')
hawk_catcher.init(token)
hawk_python_sdk.init(token)

for _ in range(10):
try:
Expand All @@ -57,12 +57,12 @@ def random_exception():
except Exception as e:
random_username = fake.user_name()
random_email = fake.email()
hawk_catcher.send(e, {'username': random_username, 'value': random_email})
hawk_python_sdk.send(e, {'username': random_username, 'value': random_email})

for _ in range(2):
try:
random_exception()
except Exception as e:
random_username = fake.user_name()
random_email = fake.email()
hawk_catcher.send(e, {'username': random_username, 'value': random_email})
hawk_python_sdk.send(e, {'username': random_username, 'value': random_email})
2 changes: 1 addition & 1 deletion example/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
hawk-catcher
hawk-python-sdk
faker
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
dynamic = ["version"]
dependencies = ["requests"]
name = "hawk-catcher"
name = "hawk-python-sdk"
authors = [{ name = "CodeX Team", email = "team@codex.so" }]
description = "Python errors Catcher module for Hawk."
readme = "README.md"
Expand All @@ -21,7 +21,7 @@ classifiers = [
flask = ["flask"]
fastapi = ["starlette"]
[tool.hatch.version]
path = "src/hawk_catcher/__init__.py"
path = "src/hawk_python_sdk/__init__.py"
[project.urls]
Homepage = "https://github.com/codex-team/hawk.python"
Issues = "https://github.com/codex-team/hawk.python/issues"
File renamed without changes.
8 changes: 4 additions & 4 deletions src/hawk_catcher/core.py → src/hawk_python_sdk/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from base64 import b64decode
import json

import hawk_catcher
from hawk_catcher.errors import InvalidHawkToken
from hawk_catcher.types import HawkCatcherSettings, Addons, User
import hawk_python_sdk
from hawk_python_sdk.errors import InvalidHawkToken
from hawk_python_sdk.types import HawkCatcherSettings, Addons, User


class Hawk:
Expand Down Expand Up @@ -89,7 +89,7 @@ def handler(self, exc_cls: type, exc: Exception, tb: traceback, context=None, us
'backtrace': backtrace,
'release': self.params['release'],
'context': context,
'catcherVersion': hawk_catcher.__version__,
'catcherVersion': hawk_python_sdk.__version__,
'user': user,
'addons': addons
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from hawk_catcher.types import HawkCatcherSettings
from hawk_python_sdk.types import HawkCatcherSettings
from ...core import Hawk
from hawk_catcher.modules.fastapi.types import FastapiSettings, FastapiAddons
from hawk_python_sdk.modules.fastapi.types import FastapiSettings, FastapiAddons
from starlette.types import ASGIApp, Receive, Scope, Send
from starlette.requests import Request
from starlette.middleware.base import BaseHTTPMiddleware
from typing import Union
from hawk_catcher.errors import ModuleError
from hawk_python_sdk.errors import ModuleError
import asyncio
from contextvars import ContextVar
from fastapi import Request
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from hawk_catcher.types import HawkCatcherSettings, User, Addons
from hawk_python_sdk.types import HawkCatcherSettings, User, Addons
from typing import Callable, TypedDict
from starlette.applications import Starlette
from fastapi import Request
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ...core import Hawk
from typing import Union
from hawk_catcher.modules.flask.types import FlaskSettings, Addons
from hawk_catcher.errors import ModuleError
from hawk_python_sdk.modules.flask.types import FlaskSettings, Addons
from hawk_python_sdk.errors import ModuleError

try:
from flask.signals import got_request_exception
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from hawk_catcher.types import HawkCatcherSettings, User, Addons
from hawk_python_sdk.types import HawkCatcherSettings, User, Addons
from typing import Callable, TypedDict
from flask import Request

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/test_cather.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import pytest

from hawk_catcher import __version__
from hawk_catcher import Hawk
from hawk_catcher.errors import InvalidHawkToken
from hawk_python_sdk import __version__
from hawk_python_sdk import Hawk
from hawk_python_sdk.errors import InvalidHawkToken

sample_token = "eyJpbnRlZ3JhdGlvbklkIjoiZGRjZmY4OTItODMzMy00YjVlLWIyYWQtZWM1MDQ5MDVjMjFlIiwic2VjcmV0IjoiZmJjYzIwMTEtMTY5My00NDIyLThiNDItZDRlMzdlYmI4NWIwIn0="
sample_token_collector_endpoint = "https://ddcff892-8333-4b5e-b2ad-ec504905c21e.k1.hawk.so"
Expand Down

0 comments on commit c2e0d67

Please sign in to comment.