From ae9cb209a52b5f55c4123294cf6e5495bb44d5e0 Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Thu, 23 Jan 2025 11:49:39 +0100 Subject: [PATCH] Create 'bsmain' (for bugsink-main) app to hold commands As had been noted on some of the commands, 'ingest' was not the best place for them. However, [project-level apps are not supported in Django](https://forum.djangoproject.com/t/allow-project-to-have-management-commands/5220/2) So just create a 'main' app. I want to qualify it as 'myproject-main' though, to avoid further unqualified global namespace pollution. And I want to avoid prefixing with 'bugsink' b/c that's annoying for tab-completion. So 'bs' it is. I've moved all commands over; even though a case could be made that the "feeding" commands (raise_exception, send_json, stress_test) are somewhat related to ingestion, that's not a very good case :-) --- bsmain/__init__.py | 0 bsmain/admin.py | 0 bsmain/apps.py | 6 ++++++ bsmain/management/__init__.py | 0 bsmain/management/commands/__init__.py | 0 {ingest => bsmain}/management/commands/check_migrations.py | 0 .../management/commands/fetch_event_schema_json.py | 0 {ingest => bsmain}/management/commands/prestart.py | 0 {ingest => bsmain}/management/commands/raise_exception.py | 0 {ingest => bsmain}/management/commands/send_json.py | 0 {ingest => bsmain}/management/commands/showstat.py | 1 - {ingest => bsmain}/management/commands/stress_test.py | 0 bsmain/migrations/__init__.py | 0 bsmain/models.py | 0 bsmain/tests.py | 0 bsmain/views.py | 0 bugsink/settings/default.py | 1 + ingest/tests.py | 2 +- pyproject.toml | 1 + 19 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 bsmain/__init__.py create mode 100644 bsmain/admin.py create mode 100644 bsmain/apps.py create mode 100644 bsmain/management/__init__.py create mode 100644 bsmain/management/commands/__init__.py rename {ingest => bsmain}/management/commands/check_migrations.py (100%) rename {ingest => bsmain}/management/commands/fetch_event_schema_json.py (100%) rename {ingest => bsmain}/management/commands/prestart.py (100%) rename {ingest => bsmain}/management/commands/raise_exception.py (100%) rename {ingest => bsmain}/management/commands/send_json.py (100%) rename {ingest => bsmain}/management/commands/showstat.py (79%) rename {ingest => bsmain}/management/commands/stress_test.py (100%) create mode 100644 bsmain/migrations/__init__.py create mode 100644 bsmain/models.py create mode 100644 bsmain/tests.py create mode 100644 bsmain/views.py diff --git a/bsmain/__init__.py b/bsmain/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bsmain/admin.py b/bsmain/admin.py new file mode 100644 index 0000000..e69de29 diff --git a/bsmain/apps.py b/bsmain/apps.py new file mode 100644 index 0000000..aab9bf3 --- /dev/null +++ b/bsmain/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class BsmainConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "bsmain" diff --git a/bsmain/management/__init__.py b/bsmain/management/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bsmain/management/commands/__init__.py b/bsmain/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ingest/management/commands/check_migrations.py b/bsmain/management/commands/check_migrations.py similarity index 100% rename from ingest/management/commands/check_migrations.py rename to bsmain/management/commands/check_migrations.py diff --git a/ingest/management/commands/fetch_event_schema_json.py b/bsmain/management/commands/fetch_event_schema_json.py similarity index 100% rename from ingest/management/commands/fetch_event_schema_json.py rename to bsmain/management/commands/fetch_event_schema_json.py diff --git a/ingest/management/commands/prestart.py b/bsmain/management/commands/prestart.py similarity index 100% rename from ingest/management/commands/prestart.py rename to bsmain/management/commands/prestart.py diff --git a/ingest/management/commands/raise_exception.py b/bsmain/management/commands/raise_exception.py similarity index 100% rename from ingest/management/commands/raise_exception.py rename to bsmain/management/commands/raise_exception.py diff --git a/ingest/management/commands/send_json.py b/bsmain/management/commands/send_json.py similarity index 100% rename from ingest/management/commands/send_json.py rename to bsmain/management/commands/send_json.py diff --git a/ingest/management/commands/showstat.py b/bsmain/management/commands/showstat.py similarity index 79% rename from ingest/management/commands/showstat.py rename to bsmain/management/commands/showstat.py index e8ccfd4..0860fc3 100644 --- a/ingest/management/commands/showstat.py +++ b/bsmain/management/commands/showstat.py @@ -4,7 +4,6 @@ from snappea.models import Task class Command(BaseCommand): - # "ingest" may not be the best place for this, but "bugsink" is not an app, so Django won't discover it. def add_arguments(self, parser): parser.add_argument( diff --git a/ingest/management/commands/stress_test.py b/bsmain/management/commands/stress_test.py similarity index 100% rename from ingest/management/commands/stress_test.py rename to bsmain/management/commands/stress_test.py diff --git a/bsmain/migrations/__init__.py b/bsmain/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bsmain/models.py b/bsmain/models.py new file mode 100644 index 0000000..e69de29 diff --git a/bsmain/tests.py b/bsmain/tests.py new file mode 100644 index 0000000..e69de29 diff --git a/bsmain/views.py b/bsmain/views.py new file mode 100644 index 0000000..e69de29 diff --git a/bugsink/settings/default.py b/bugsink/settings/default.py index 15bfff6..f42e4e8 100644 --- a/bugsink/settings/default.py +++ b/bugsink/settings/default.py @@ -65,6 +65,7 @@ INSTALLED_APPS = [ ] BUGSINK_APPS = [ + 'bsmain', 'phonehome', 'users', 'theme', diff --git a/ingest/tests.py b/ingest/tests.py index e5e39ce..af35b1b 100644 --- a/ingest/tests.py +++ b/ingest/tests.py @@ -23,7 +23,7 @@ from issues.models import IssueStateManager, Issue, TurningPoint, TurningPointKi from bugsink.app_settings import override_settings from compat.timestamp import format_timestamp from compat.dsn import get_header_value -from ingest.management.commands.send_json import Command as SendJsonCommand +from bsmain.management.commands.send_json import Command as SendJsonCommand from .views import BaseIngestAPIView from .parsers import readuntil, NewlineFinder, ParseError, LengthFinder, StreamingEnvelopeParser diff --git a/pyproject.toml b/pyproject.toml index 12984d5..b817f81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ where = ["."] include = [ "alerts*", "api*", + "bsmain*", "bugsink*", "compat*", "events*",