Files
zulip/zerver/management/commands/transfer_uploads_to_s3.py
Anders Kaseorg 365fe0b3d5 python: Sort imports with isort.
Fixes #2665.

Regenerated by tabbott with `lint --fix` after a rebase and change in
parameters.

Note from tabbott: In a few cases, this converts technical debt in the
form of unsorted imports into different technical debt in the form of
our largest files having very long, ugly import sequences at the
start.  I expect this change will increase pressure for us to split
those files, which isn't a bad thing.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-11 16:45:32 -07:00

29 lines
1018 B
Python

from typing import Any
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError, CommandParser
from zerver.lib.transfer import transfer_uploads_to_s3
class Command(BaseCommand):
help = """Transfer uploads to S3 """
def add_arguments(self, parser: CommandParser) -> None:
parser.add_argument('--processes',
dest='processes',
action="store",
default=6,
help='Processes to use for exporting uploads in parallel')
def handle(self, *args: Any, **options: Any) -> None:
num_processes = int(options['processes'])
if num_processes < 1:
raise CommandError('You must have at least one process.')
if not settings.LOCAL_UPLOADS_DIR:
raise CommandError('Please set the value of LOCAL_UPLOADS_DIR.')
transfer_uploads_to_s3(num_processes)
print("Transfer to S3 completed successfully.")