Esempio n. 1
0
def loop_locations(fn, bucket_base_name):
    """
    Loop over all S3 locations and execute function fn.
    """
    from botocross.s3 import RegionMap, class_iterator
    
    s3 = boto.connect_s3()
    locations = class_iterator(boto.s3.connection.Location)
    for location in locations:
        region = RegionMap[location]
        bucket_name = bucket_base_name + '-' + region
        try:
            fn(s3, bucket_name, location=getattr(boto.s3.connection.Location, location))
        except boto.exception.BotoServerError, e:
            log.error(e.error_message)
Esempio n. 2
0
import os

# configure command line argument parsing
parser = argparse.ArgumentParser(
    description='Upload a file to a S3 bucket in all/some available S3 regions',
    parents=[bc.build_region_parser(),
             bc.build_common_parser()])
parser.add_argument("bucket", help="A bucket name (will get region suffix)")
parser.add_argument("file", help="A local file (e.g. ./test.txt)")
args = parser.parse_args()

# process common command line arguments
log = logging.getLogger('botocross')
bc.configure_logging(log, args.log_level)
credentials = bc.parse_credentials(args)
locations = bc.filter_regions_s3(class_iterator(Location), args.region)

# execute business logic
log.info("Uploading to S3 buckets named '" + args.bucket + "':")

file = open(args.file, 'r')
filePath, fileName = os.path.split(file.name)
log.debug(filePath)
log.debug(fileName)

s3 = boto.connect_s3(**credentials)

for location in locations:
    region = RegionMap[location]
    pprint(region, indent=2)
    try:
Esempio n. 3
0
import botocross as bc
import logging
import os

# configure command line argument parsing
parser = argparse.ArgumentParser(description='Upload a file to a S3 bucket in all/some available S3 regions',
                                 parents=[bc.build_region_parser(), bc.build_common_parser()])
parser.add_argument("bucket", help="A bucket name (will get region suffix)")
parser.add_argument("file", help="A local file (e.g. ./test.txt)")
args = parser.parse_args()

# process common command line arguments
log = logging.getLogger('botocross')
bc.configure_logging(log, args.log_level)
credentials = bc.parse_credentials(args)
locations = bc.filter_regions_s3(class_iterator(Location), args.region)

# execute business logic
log.info("Uploading to S3 buckets named '" + args.bucket + "':")

file = open(args.file, 'r')
filePath, fileName = os.path.split(file.name)
log.debug(filePath)
log.debug(fileName)

s3 = boto.connect_s3(**credentials)

for location in locations:
    region = RegionMap[location]
    pprint(region, indent=2)
    try: