示例#1
0
		if not key.name in files:
				pool.apply_async(worker, args=(region_endpoints['publicURL'],
												ca.conf['container'],
												ca.creds['token'],
												key.name,
												ca.conf['s3bucket'],
												ca.conf['s3accesskey'].encode('ascii'),
												ca.conf['s3secretkey'].encode('ascii')))

	pool.join()
	
	if ca.conf.get('emailreport') and copied_files:
		ca.log("Sending email.")
		ca.email("Copied "+str(len(copied_files))+" files to "+ca.conf['container'],'''
	Copied the follow files from S3 bucket %s to Swift container %s:
	
%s
	''' % (ca.conf['s3bucket'],ca.conf['container'],"\n".join(copied_files)))

	ca.log("Done.",'',100)

		
		


def worker(endpoint,container,token,key_name,bucket,accesskey,secretkey):


	#ca.log("Starting "+str(key_name))
	my_s3 = S3Connection(accesskey,secretkey)
	my_bucket = Bucket(connection=my_s3, name=bucket)
示例#2
0
        if not key.name in files:
            pool.apply_async(worker,
                             args=(region_endpoints['publicURL'],
                                   ca.conf['container'], ca.creds['token'],
                                   key.name, ca.conf['s3bucket'],
                                   ca.conf['s3accesskey'].encode('ascii'),
                                   ca.conf['s3secretkey'].encode('ascii')))

    pool.join()

    if ca.conf.get('emailreport') and copied_files:
        ca.log("Sending email.")
        ca.email(
            "Copied " + str(len(copied_files)) + " files to " +
            ca.conf['container'], '''
	Copied the follow files from S3 bucket %s to Swift container %s:
	
%s
	''' % (ca.conf['s3bucket'], ca.conf['container'], "\n".join(copied_files)))

    ca.log("Done.", '', 100)


def worker(endpoint, container, token, key_name, bucket, accesskey, secretkey):

    #ca.log("Starting "+str(key_name))
    my_s3 = S3Connection(accesskey, secretkey)
    my_bucket = Bucket(connection=my_s3, name=bucket)
    key = Key(my_bucket)
    key.key = key_name
    if key.name[-1] == "/" and key.size == 0: