1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-03 17:50:11 +02:00

if the AWS S3 bucket does not exist, create it

This makes the AWS S3 setup dead simple: just put in a awsbucket name of
your choosing, set the AWS credentials, and it'll do the rest, whether the
bucket exists already or not.  S3 buckets are trivial to delete too, in
case of error: `s3cmd rb s3://mybadbucketname`.
This commit is contained in:
Hans-Christoph Steiner 2014-04-22 23:11:58 -04:00
parent f0def08add
commit 98033f3270
2 changed files with 7 additions and 3 deletions

View File

@ -38,7 +38,7 @@ def update_awsbucket(repo_section):
import libcloud.security
libcloud.security.VERIFY_SSL_CERT = True
from libcloud.storage.types import Provider
from libcloud.storage.types import Provider, ContainerDoesNotExistError
from libcloud.storage.providers import get_driver
if 'awsaccesskeyid' not in config or 'awssecretkey' not in config:
@ -48,7 +48,11 @@ def update_awsbucket(repo_section):
cls = get_driver(Provider.S3)
driver = cls(config['awsaccesskeyid'], config['awssecretkey'])
container = driver.get_container(container_name=awsbucket)
try:
container = driver.get_container(container_name=awsbucket)
except ContainerDoesNotExistError:
container = driver.create_container(container_name=awsbucket)
logging.info('Created new container "' + container.name + '"')
upload_dir = 'fdroid/' + repo_section
if options.verbose:

View File

@ -32,7 +32,7 @@ setup(name='fdroidserver',
'paramiko',
'PIL',
'python-magic',
'apache-libcloud >= 0.5',
'apache-libcloud >= 0.14.1',
],
classifiers=[
'Development Status :: 3 - Alpha',