mirror of https://github.com/zulip/zulip.git
upload: Replace boto3.Session with boto3.session.Session.
boto3-stubs seems to have dropped the former for some reason. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
b945aa3443
commit
2508b579a6
|
@ -14,7 +14,7 @@ import secrets
|
|||
from contextlib import contextmanager
|
||||
from typing import Iterator, List, Tuple, TypedDict
|
||||
|
||||
import boto3
|
||||
import boto3.session
|
||||
import orjson
|
||||
from django.conf import settings
|
||||
from mypy_boto3_ses import SESClient
|
||||
|
@ -30,7 +30,7 @@ class IdentityArgsDict(TypedDict, total=False):
|
|||
|
||||
def main() -> None:
|
||||
|
||||
session = boto3.Session()
|
||||
session = boto3.session.Session()
|
||||
|
||||
from_address = settings.NOREPLY_EMAIL_ADDRESS
|
||||
from_host = Address(addr_spec=from_address).domain
|
||||
|
@ -69,7 +69,7 @@ def main() -> None:
|
|||
print_messages(session, queue_url)
|
||||
|
||||
|
||||
def get_ses_arn(session: boto3.Session, args: argparse.Namespace) -> str:
|
||||
def get_ses_arn(session: boto3.session.Session, args: argparse.Namespace) -> str:
|
||||
ses: SESClient = session.client("ses")
|
||||
|
||||
notification_settings = ses.get_identity_notification_attributes(Identities=[args.identity])
|
||||
|
@ -85,7 +85,7 @@ def get_ses_arn(session: boto3.Session, args: argparse.Namespace) -> str:
|
|||
|
||||
|
||||
@contextmanager
|
||||
def our_sqs_queue(session: boto3.Session, ses_topic_arn: str) -> Iterator[Tuple[str, str]]:
|
||||
def our_sqs_queue(session: boto3.session.Session, ses_topic_arn: str) -> Iterator[Tuple[str, str]]:
|
||||
(_, _, _, region, account_id, topic_name) = ses_topic_arn.split(":")
|
||||
|
||||
sqs: SQSClient = session.client("sqs")
|
||||
|
@ -122,7 +122,7 @@ def our_sqs_queue(session: boto3.Session, ses_topic_arn: str) -> Iterator[Tuple[
|
|||
|
||||
@contextmanager
|
||||
def our_sns_subscription(
|
||||
session: boto3.Session, ses_topic_arn: str, queue_arn: str
|
||||
session: boto3.session.Session, ses_topic_arn: str, queue_arn: str
|
||||
) -> Iterator[str]:
|
||||
sns: SNSClient = session.client("sns")
|
||||
try:
|
||||
|
@ -141,7 +141,7 @@ def our_sns_subscription(
|
|||
sns.unsubscribe(SubscriptionArn=subscription_arn)
|
||||
|
||||
|
||||
def print_messages(session: boto3.Session, queue_url: str) -> None:
|
||||
def print_messages(session: boto3.session.Session, queue_url: str) -> None:
|
||||
sqs: SQSClient = session.client("sqs")
|
||||
try:
|
||||
while True:
|
||||
|
|
|
@ -12,7 +12,7 @@ from scripts.lib.setup_path import setup_path
|
|||
|
||||
setup_path()
|
||||
|
||||
import boto3
|
||||
import boto3.session
|
||||
from mypy_boto3_s3 import S3Client
|
||||
from natsort import natsorted
|
||||
|
||||
|
@ -37,7 +37,7 @@ new_basename = os.path.basename(args.filename)
|
|||
if not new_basename.startswith("zulip-server-") or not new_basename.endswith(".tar.gz"):
|
||||
parser.error("File does not match zulip-server-*.tar.gz")
|
||||
|
||||
session = boto3.Session()
|
||||
session = boto3.session.Session()
|
||||
client: S3Client = session.client("s3")
|
||||
bucket = session.resource("s3", region_name="us-east-1").Bucket("zulip-download")
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ from typing import (
|
|||
)
|
||||
from unittest import mock
|
||||
|
||||
import boto3
|
||||
import boto3.session
|
||||
import fakeldap
|
||||
import ldap
|
||||
import orjson
|
||||
|
@ -564,7 +564,7 @@ def use_s3_backend(method: FuncT) -> FuncT:
|
|||
|
||||
|
||||
def create_s3_buckets(*bucket_names: str) -> List[Bucket]:
|
||||
session = boto3.Session(settings.S3_KEY, settings.S3_SECRET_KEY)
|
||||
session = boto3.session.Session(settings.S3_KEY, settings.S3_SECRET_KEY)
|
||||
s3 = session.resource("s3")
|
||||
buckets = [s3.create_bucket(Bucket=name) for name in bucket_names]
|
||||
return buckets
|
||||
|
|
|
@ -331,7 +331,7 @@ class ZulipUploadBackend:
|
|||
|
||||
def get_bucket(bucket_name: str, session: Optional[Session] = None) -> Bucket:
|
||||
if session is None:
|
||||
session = boto3.Session(settings.S3_KEY, settings.S3_SECRET_KEY)
|
||||
session = Session(settings.S3_KEY, settings.S3_SECRET_KEY)
|
||||
bucket = session.resource(
|
||||
"s3", region_name=settings.S3_REGION, endpoint_url=settings.S3_ENDPOINT_URL
|
||||
).Bucket(bucket_name)
|
||||
|
@ -418,7 +418,7 @@ def get_signed_upload_url(path: str, download: bool = False) -> str:
|
|||
|
||||
class S3UploadBackend(ZulipUploadBackend):
|
||||
def __init__(self) -> None:
|
||||
self.session = boto3.Session(settings.S3_KEY, settings.S3_SECRET_KEY)
|
||||
self.session = Session(settings.S3_KEY, settings.S3_SECRET_KEY)
|
||||
self.avatar_bucket = get_bucket(settings.S3_AVATAR_BUCKET, self.session)
|
||||
self.uploads_bucket = get_bucket(settings.S3_AUTH_UPLOADS_BUCKET, self.session)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
import shutil
|
||||
|
||||
import boto3
|
||||
import boto3.session
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditor
|
||||
|
@ -61,7 +61,7 @@ class LocalUploader(Uploader):
|
|||
class S3Uploader(Uploader):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
session = boto3.Session(settings.S3_KEY, settings.S3_SECRET_KEY)
|
||||
session = boto3.session.Session(settings.S3_KEY, settings.S3_SECRET_KEY)
|
||||
self.bucket_name = settings.S3_AVATAR_BUCKET
|
||||
self.bucket = session.resource(
|
||||
"s3", region_name=settings.S3_REGION, endpoint_url=settings.S3_ENDPOINT_URL
|
||||
|
|
Loading…
Reference in New Issue