当前位置: 首页>>代码示例>>Python>>正文


Python Bucket.get_all_keys方法代码示例

本文整理汇总了Python中boto.s3.bucket.Bucket.get_all_keys方法的典型用法代码示例。如果您正苦于以下问题:Python Bucket.get_all_keys方法的具体用法?Python Bucket.get_all_keys怎么用?Python Bucket.get_all_keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boto.s3.bucket.Bucket的用法示例。


在下文中一共展示了Bucket.get_all_keys方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Compost

# 需要导入模块: from boto.s3.bucket import Bucket [as 别名]
# 或者: from boto.s3.bucket.Bucket import get_all_keys [as 别名]
class Compost(object):

    def __init__(self, directory, bucket):
        self.directory = directory
        self.bucket = Bucket(connection=boto.connect_s3(), name=bucket)

    def turn(self):
        """
        'Turn' the compost, i.e. make a backup of all files in the local directory.
        """
        for filename, full_path in self._local_files():
            logger.debug('backing up {}'.format(filename))
            key = self.bucket.new_key(filename)
            key.set_contents_from_filename(full_path)

    def list(self):
        """Return a list of known backed up files."""
        return [k.name for k in self.bucket.get_all_keys()]

    def read(self, filename):
        """
        Return the contents of named file, or the empty string if the files does not exist.
        """
        return self.bucket.get_key(filename).get_contents_as_string()


    def _local_files(self):
        for f in os.listdir(self.directory):
            yield f, os.path.join(self.directory, f)
开发者ID:fredrik,项目名称:compost,代码行数:31,代码来源:compost.py

示例2: empty_bucket

# 需要导入模块: from boto.s3.bucket import Bucket [as 别名]
# 或者: from boto.s3.bucket.Bucket import get_all_keys [as 别名]
def empty_bucket(bucket_name):
    """Destructive helper."""
    import boto
    from boto.s3.bucket import Bucket

    bucket = Bucket(connection=boto.connect_s3(), name=bucket_name)
    for key in bucket.get_all_keys():
        key.delete()
开发者ID:fredrik,项目名称:compost,代码行数:10,代码来源:test_compost.py

示例3: get_bucket

# 需要导入模块: from boto.s3.bucket import Bucket [as 别名]
# 或者: from boto.s3.bucket.Bucket import get_all_keys [as 别名]
 def get_bucket(self, bucket_name, validate=True):
     bucket = Bucket(self, bucket_name)
     if validate:
         rs = bucket.get_all_keys(None, maxkeys=0)
     return bucket
开发者ID:Noirad,项目名称:Amazon-VOD.bundle,代码行数:7,代码来源:connection.py

示例4: get_bucket

# 需要导入模块: from boto.s3.bucket import Bucket [as 别名]
# 或者: from boto.s3.bucket.Bucket import get_all_keys [as 别名]
 def get_bucket(self, bucket_name, validate=True, headers=None):
     bucket = Bucket(self, bucket_name)
     if validate:
         bucket.get_all_keys(headers, maxkeys=0)
     return bucket
开发者ID:molddu,项目名称:tiramola,代码行数:7,代码来源:connection.py

示例5: dirwalk

# 需要导入模块: from boto.s3.bucket import Bucket [as 别名]
# 或者: from boto.s3.bucket.Bucket import get_all_keys [as 别名]
def dirwalk(dir):
    for f in os.listdir(dir):
        fullpath = os.path.join(dir,f)
        if os.path.isdir(fullpath) and not os.path.islink(fullpath):
            for x in dirwalk(fullpath):
                yield x
        else:
            yield fullpath


bucketname = 'ergometria.async.fi'

connection = boto.connect_s3()
bucket = Bucket(connection, bucketname)
keynames = [key.name for key in bucket.get_all_keys(prefix='data/')]

datafile_uploaded = False
for filename in dirwalk('data/'):
    if not filename in keynames and not filename.endswith('.json'):
        datafile_uploaded = True
        print 'uploading', filename
        k = Key(bucket)
        k.key = filename
        k.set_contents_from_filename(filename)
        
        
if True: #datafile_uploaded:
    k = Key(bucket)
    k.key = 'data/index.json'
    sessions = []
开发者ID:kahara,项目名称:pyergometer,代码行数:32,代码来源:upload.py

示例6: get_bucket

# 需要导入模块: from boto.s3.bucket import Bucket [as 别名]
# 或者: from boto.s3.bucket.Bucket import get_all_keys [as 别名]
 def get_bucket(self, bucket_name, validate=True):
     bucket = Bucket(self, bucket_name, headers=self.headers)
     if validate:
         rs = bucket.get_all_keys(maxkeys=0)
     return bucket
开发者ID:turnkeylinux,项目名称:python-boto,代码行数:7,代码来源:connection.py

示例7: get_bucket

# 需要导入模块: from boto.s3.bucket import Bucket [as 别名]
# 或者: from boto.s3.bucket.Bucket import get_all_keys [as 别名]
 def get_bucket(self, bucket_name):
     bucket = Bucket(self, bucket_name)
     rs = bucket.get_all_keys(None, maxkeys=0)
     return bucket
开发者ID:jspring11,项目名称:boto,代码行数:6,代码来源:connection.py


注:本文中的boto.s3.bucket.Bucket.get_all_keys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。