2017-08-28 38 views
0

我正在使用Boto s3程序包来查看我的存储桶的所有内容。如果我做这样的事情Python Amazon Boto S3正在运行的错误

bucket = s3.get_bucket('my_bucket_name') 
for k in bucket: 
    print k.ongoing_restore 

上面的代码片段输出无所有对象。但是,如果我得到一个特定的密钥使用:

k = bucket.get_key('my_key') 
k.ongoing_restore 

然后我得到一个True输出。出于某种原因,第一组代码中的值没有正确设置,并且无法找出原因。任何帮助感谢!

回答

0

我无法重现您的情况。

通常情况下,您可以使用.__dict__来调试对象。

这里是我的输出:

>>> import boto 
>>> s3=boto.connect_s3() 
>>> bucket = s3.get_bucket('my-bucket') 
>>> for k in bucket: 
... print k.ongoing_restore 
... 
None 
None 
None 
None 
None 
None 
None 
None 
None 
None 
None 
None 
None 
None 
None 
None 
None 
None 
None 
>>> k = bucket.get_key('foo.zip') 
>>> k.ongoing_restore 
>>> k.__dict__ 
{'content_length': '234', 'encrypted': None, 'resp': None, 'ongoing_restore': None, 'source_version_id': None, 'content_language': None, '_storage_class': None, 'owner': None, 'filename': None, 'size': 234, 'delete_marker': False, 'etag': '"..."', 'content_encoding': None, 'content_md5': None, 'content_disposition': None, 'cache_control': None, 'metadata': {}, 'expires': None, 'version_id': None, 'x_robots_tag': None, 'last_modified': 'Sun, 06 Aug 2017 03:23:22 GMT', 'content_type': 'application/json', 'date': 'Mon, 28 Aug 2017 22:40:25 GMT', 'path': None, 'is_latest': False, 'local_hashes': {}, 'name': 'foo.zip', 'bucket': <Bucket: my-bucket>, 'expiry_date': None, 'mode': None} 
>>> 
相关问题