示例#1
0
文件: s3.py 项目: okomestudio/mrjob
    def create_bucket(self, bucket_name, region=None):
        """Create a bucket on S3 with a location constraint
        matching the given region.

        .. versionchanged:: 0.6.0

           The *region* argument used to be called *location*.
        """
        client = self.make_s3_client()

        conf = {}
        if region and region != _S3_REGION_WITH_NO_LOCATION_CONSTRAINT:
            conf['LocationConstraint'] = region

        client.create_bucket(Bucket=bucket_name,
                             CreateBucketConfiguration=conf)
示例#2
0
文件: s3.py 项目: poteman/mrjob
    def create_bucket(self, bucket_name, region=None):
        """Create a bucket on S3 with a location constraint
        matching the given region.

        .. versionchanged:: 0.6.0

           The *region* argument used to be called *location*.
        """
        client = self.make_s3_client()

        conf = {}
        if region and region != _S3_REGION_WITH_NO_LOCATION_CONSTRAINT:
            conf['LocationConstraint'] = region

        client.create_bucket(Bucket=bucket_name,
                             CreateBucketConfiguration=conf)
示例#3
0
def create_bucket(bucket_name: str) -> str:

    client = boto3.client('s3')
    region = os.environ.get('AWS_DEFAULT_REGION', 'us-east-1')

    kw = {'Bucket': bucket_name}
    kw.update({CreateBucketConfiguration: {
        'LocationConstraint': region
    }} if region != 'us-east-1' else {})

    try:
        client.create_bucket(**kw)
    except botocore.exceptions.ClientError as ex:
        logger.exception(ex)
        sys.exit(1)

    return bucket_name
示例#4
0
文件: s3.py 项目: jgressma/mrjob
    def create_bucket(self, bucket_name, region=None):
        """Create a bucket on S3 with a location constraint
        matching the given region.
        """
        client = self.make_s3_client()

        params = dict(Bucket=bucket_name)

        if region is None:
            region = self._s3_region

        # CreateBucketConfiguration can't be empty, so don't set it
        # unless there's a location constraint (see #1927)
        if region and region != _S3_REGION_WITH_NO_LOCATION_CONSTRAINT:
            params['CreateBucketConfiguration'] = dict(
                LocationConstraint=region)

        client.create_bucket(**params)
示例#5
0
文件: s3.py 项目: Affirm/mrjob
    def create_bucket(self, bucket_name, region=None):
        """Create a bucket on S3 with a location constraint
        matching the given region.

        .. versionchanged:: 0.6.0

           The *region* argument used to be called *location*.
        """
        client = self.make_s3_client()

        params = dict(Bucket=bucket_name)

        # CreateBucketConfiguration can't be empty, so don't set it
        # unless there's a location constraint (see #1927)
        if region != _S3_REGION_WITH_NO_LOCATION_CONSTRAINT:
            params['CreateBucketConfiguration'] = dict(
                LocationConstraint=region)

        client.create_bucket(**params)
示例#6
0
    def create_bucket(self, bucket_name, region=None):
        """Create a bucket on S3 with a location constraint
        matching the given region.

        .. versionchanged:: 0.6.0

           The *region* argument used to be called *location*.
        """
        client = self.make_s3_client()

        params = dict(Bucket=bucket_name)

        # CreateBucketConfiguration can't be empty, so don't set it
        # unless there's a location constraint (see #1927)
        if region != _S3_REGION_WITH_NO_LOCATION_CONSTRAINT:
            params['CreateBucketConfiguration'] = dict(
                LocationConstraint=region)

        client.create_bucket(**params)