bversion/backup/s3_interface.py
def connect(config):
    """ Connect to S3 and ensure that versioning is enabled """

    access_key = config['s3']['access_key']
    secret_key = config['s3']['secret_key']

    if 'endpoint' in config['s3']:
        client = boto3.client( 's3',
                            endpoint_url = config['s3']['endpoint'],
                            aws_access_key_id=access_key,
                            aws_secret_access_key=secret_key)
    else:
        client = boto3.client( 's3',
                            aws_access_key_id=access_key,
                            aws_secret_access_key=secret_key)

    bucket_versioning = client.get_bucket_versioning(Bucket=config['s3']['bucket'])
    if bucket_versioning['Status'] != 'Enabled':
        print('Bucket versioning must be enabled, attempting to enable, please restart application')
        client.put_bucket_versioning(Bucket=config['s3']['bucket'], VersioningConfiguration={'Status': 'Enabled' })
        raise SystemExit(0)
    return {'client' : client, 'bucket' : config['s3']['bucket']}
 Connect to S3 and ensure that versioning is enabled 
Connect to S3 and ensure that versioning is enabled
Connect to S3 and ensure that versioning is enabled
def connect(config):
    access_key = config['s3']['access_key']
    secret_key = config['s3']['secret_key']
    if 'endpoint' in config['s3']:
        client = boto3.client( 's3',
                            endpoint_url = config['s3']['endpoint'],
                            aws_access_key_id=access_key,
                            aws_secret_access_key=secret_key)
    else:
        client = boto3.client( 's3',
                            aws_access_key_id=access_key,
                            aws_secret_access_key=secret_key)
    bucket_versioning = client.get_bucket_versioning(Bucket=config['s3']['bucket'])
    if bucket_versioning['Status'] != 'Enabled':
        print('Bucket versioning must be enabled, attempting to enable, please restart application')
        client.put_bucket_versioning(Bucket=config['s3']['bucket'], VersioningConfiguration={'Status': 'Enabled' })
        raise SystemExit(0)
    return {'client' : client, 'bucket' : config['s3']['bucket']}
def connect ( config ) : access_key = config [ 's3' ] [ 'access_key' ] secret_key = config [ 's3' ] [ 'secret_key' ] if 'endpoint' in config [ 's3' ] : client = boto3 . client ( 's3' , endpoint_url = config [ 's3' ] [ 'endpoint' ] , aws_access_key_id = access_key , aws_secret_access_key = secret_key ) else : client = boto3 . client ( 's3' , aws_access_key_id = access_key , aws_secret_access_key = secret_key ) bucket_versioning = client . get_bucket_versioning ( Bucket = config [ 's3' ] [ 'bucket' ] ) if bucket_versioning [ 'Status' ] != 'Enabled' : print ( 'Bucket versioning must be enabled, attempting to enable, please restart application' ) client . put_bucket_versioning ( Bucket = config [ 's3' ] [ 'bucket' ] , VersioningConfiguration = { 'Status' : 'Enabled' } ) raise SystemExit ( 0 ) return { 'client' : client , 'bucket' : config [ 's3' ] [ 'bucket' ] }
Connect to S3 and ensure that versioning is enabled
Connect to S3 and ensure that versioning is enabled
""" Connect to S3 and ensure that versioning is enabled """
config