Skip to content

Commit 4eca992

Browse files
committed
Port to Python 3
1 parent ac1a9e6 commit 4eca992

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1802
-5540
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ cover/
5959

6060
# Django stuff:
6161
*.log
62-
local_settings.py
62+
local_config.py
6363
db.sqlite3
6464
db.sqlite3-journal
6565

README.md

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# error-tracker
2+
23
Code behind https://errors.ubuntu.com
34

45

@@ -14,26 +15,49 @@ sudo snap install charmcraft --classic
1415
charmcraft.spread -v -reuse -resend
1516
```
1617

17-
## Running the tests locally for development
18+
## Setting up local development
1819

1920

2021
Start with the Python dependencies
2122
```
22-
sudo apt install apport-retrace python3-amqp python3-bson python3-cassandra python3-flask python3-mock python3-pygit2 python3-pytest python3-pytest-cov python3-swiftclient ubuntu-dbgsym-keyring
23+
sudo apt install apport-retrace python3-amqp python3-bson python3-cassandra python3-flask python3-mock python3-pygit2 python3-pytest python3-pytest-cov python3-swiftclient ubuntu-dbgsym-keyring
2324
```
2425

25-
Then by having a local Cassandra and RabbitMQ:
26+
Then start a local Cassandra, RabbitMQ and swift (`docker` should works fine too):
2627
```
27-
docker run --name cassandra --network host --rm -d docker.io/cassandra
28-
docker run --name rabbitmq --network host --rm -d docker.io/rabbitmq
28+
podman run --name cassandra --network host --rm -d -e HEAP_NEWSIZE=10M -e MAX_HEAP_SIZE=200M docker.io/cassandra
29+
podman run --name rabbitmq --network host --rm -d docker.io/rabbitmq
30+
podman run --name swift --network host --rm -d docker.io/openstackswift/saio
2931
```
30-
And then run the tests with `pytest`:
32+
33+
You can then then run the tests with `pytest`:
3134
```
3235
cd src
33-
pytest -o log_cli=1 -vv --log-level=INFO tests/
36+
python3 -m pytest -o log_cli=1 -vv --log-level=INFO tests/
3437
```
3538

36-
## Documentation
39+
Or start each individual process (from the `./src` folder):
40+
41+
daisy:
42+
```
43+
python3 ./daisy/app.py
44+
```
45+
46+
retracer:
47+
```
48+
python3 ./retracer.py -a amd64 --sandbox-dir /tmp/sandbox -v --config-dir ./retracer/config
49+
```
50+
51+
From there, you can manually upload a crash with the following, from any folder
52+
containing a `.crash` file with its corresponding `.upload` file:
53+
```
54+
CRASH_DB_URL=http://127.0.0.1:5000 APPORT_REPORT_DIR=$(pwd) CRASH_DB_IDENTIFIER=my_custom_machine_id whoopsie --no-polling -f
55+
```
56+
This will create a corresponding `.uploaded` file containing the OOPS ID, that
57+
you need to delete if you want to upload the crash again.
58+
59+
60+
## More documentation
3761

3862
### Opening a new series
3963

pyproject.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
name = "error-tracker"
33
requires-python = ">=3.8"
44
dynamic = ["version"]
5-
dependencies = [
6-
"jubilant>=1.3.0",
7-
"pytest>=8.3.5",
8-
]
95

6+
[project.optional-dependencies]
7+
dev = [
8+
"jubilant",
9+
"pytest",
10+
]
1011

1112
[tool.setuptools.dynamic]
1213
version = {attr = "src.errortracker.__version__"}
@@ -19,3 +20,6 @@ extend-exclude = ["__pycache__", "*.egg_info"]
1920
[tool.ruff.lint]
2021
select = ["E", "F", "W", "Q", "I"]
2122
ignore = ["E501"]
23+
24+
[tool.pytest]
25+
pythonpath = ["./src", "./local_config"]

src/Makefile

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/daisy/__init__.py

Lines changed: 0 additions & 168 deletions
This file was deleted.

src/daisy/app.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from flask import Flask, request
2+
from flask.logging import default_handler
3+
4+
from daisy.submit import submit
5+
from daisy.submit_core import submit_core
6+
from errortracker import cassandra, config
7+
8+
config.logger.addHandler(default_handler)
9+
app = Flask(__name__)
10+
11+
12+
@app.route("/<system_token>", methods=["POST"])
13+
def handle_submit(system_token):
14+
return submit(request, system_token)
15+
16+
17+
@app.route("/<oopsid>/submit-core/<architecture>/<system_token>", methods=["POST"])
18+
def handle_submit_core(oopsid, architecture, system_token):
19+
return submit_core(request, oopsid, architecture, system_token)
20+
21+
22+
def __main__():
23+
cassandra.setup_cassandra()
24+
app.run(host="0.0.0.0", debug=True)
25+
26+
27+
if __name__ == "__main__":
28+
__main__()

src/daisy/cassandra_schema.py

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)