mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-10-12 02:26:09 -05:00
Chore: Cleanup command arguments and standardize process count handling (#4541)
Cleans up some command help text and adds more control over process count for command with a Pool
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
import os
|
||||
from argparse import RawTextHelpFormatter
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.management.base import BaseCommand
|
||||
@@ -8,20 +9,22 @@ logger = logging.getLogger("paperless.management.superuser")
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = """
|
||||
Creates a Django superuser:
|
||||
User named: admin
|
||||
Email: root@localhost
|
||||
with password based on env variable.
|
||||
No superuser will be created, when:
|
||||
- The username is taken already exists
|
||||
- A superuser already exists
|
||||
- PAPERLESS_ADMIN_PASSWORD is not set
|
||||
""".replace(
|
||||
" ",
|
||||
"",
|
||||
help = (
|
||||
"Creates a Django superuser:\n"
|
||||
" User named: admin\n"
|
||||
" Email: root@localhost\n"
|
||||
" Password: based on env variable PAPERLESS_ADMIN_PASSWORD\n"
|
||||
"No superuser will be created, when:\n"
|
||||
" - The username is taken already exists\n"
|
||||
" - A superuser already exists\n"
|
||||
" - PAPERLESS_ADMIN_PASSWORD is not set"
|
||||
)
|
||||
|
||||
def create_parser(self, *args, **kwargs):
|
||||
parser = super().create_parser(*args, **kwargs)
|
||||
parser.formatter_class = RawTextHelpFormatter
|
||||
return parser
|
||||
|
||||
def handle(self, *args, **options):
|
||||
username = os.getenv("PAPERLESS_ADMIN_USER", "admin")
|
||||
mail = os.getenv("PAPERLESS_ADMIN_MAIL", "root@localhost")
|
||||
|
Reference in New Issue
Block a user