eudicots / Cactus

Static site generator for designers. Uses Python and Django templates.
BSD 3-Clause "New" or "Revised" License
3.47k stars 313 forks source link

handle us-east-1 when creating bucket #180

Closed ibarria0 closed 8 years ago

ibarria0 commented 9 years ago

Boto will give an error when tryng to create a bucket on region us-east-1 because this issue https://github.com/boto/boto3/issues/125

It seems that you need to use an empty string instead of the actual "us-east-1" to specify that location.

Im proposing to do this:

    def create_bucket(self):
        """
        :returns: The newly created bucket
        """
        # S3 does not accept "us-east-1" must use "" instead
        location = self._get_bucket_region()
        if location == "us-east-1":
            location = ""
        try:
            bucket = self.get_connection().create_bucket(self.bucket_name,
                policy='public-read', location=location
            )
        except S3CreateError:
            logger.info(
                'Bucket with name %s already is used by someone else, '
                'please try again with another name', self.bucket_name)
            return  #TODO: These should be exceptions

        # Configure S3 to use the index.html and error.html files for indexes and 404/500s.
        bucket.configure_website(self._index_page, self._error_page)

        return bucket

All test pass

krallin commented 8 years ago

Looks like this was fixed here: https://github.com/koenbok/Cactus/commit/55e49bb896826039553c68266fb1e2bdbf2a3581

Sorry about not getting to your PR earlier — I think you and @koenbok might have run into the same issue separately.

Cheers