import.py 818 B

123456789101112131415161718192021222324
  1. from asgiref.sync import async_to_sync
  2. from django.core.management.base import BaseCommand
  3. from apps.importer.importer import GlitchTipImporter
  4. class Command(BaseCommand):
  5. help = "Import data from another GlitchTip instance or Sentry"
  6. def add_arguments(self, parser):
  7. parser.add_argument("url", type=str)
  8. parser.add_argument("auth_token", type=str)
  9. parser.add_argument("organization_slug", type=str)
  10. @async_to_sync
  11. async def handle(self, *args, **options):
  12. url = options["url"].rstrip("/")
  13. if not url.startswith("http"):
  14. url = "https://" + url
  15. importer = GlitchTipImporter(
  16. url, options["auth_token"], options["organization_slug"], create_users=True
  17. )
  18. await importer.check_auth()
  19. await importer.run()