-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboto_key_fetch.py
More file actions
executable file
·30 lines (22 loc) · 994 Bytes
/
Copy pathboto_key_fetch.py
File metadata and controls
executable file
·30 lines (22 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python3
from boto3 import client
from botocore import UNSIGNED
from botocore.client import Config
import datetime
conn = client('s3', region_name='us-east-1', config=Config(signature_version=UNSIGNED, retries={'max_attempts':3}))
bucket = conn.list_objects(Bucket='noaa-goes16')['Contents']
paginator = conn.get_paginator("list_objects")
page_iterator = paginator.paginate(Bucket='noaa-goes16')
for page in page_iterator:
if 'Contents' in page:
for key in page['Contents']:
print(key['Key'])
#get_last_modified = lambda obj: int(obj['LastModified'].strftime('%s'))
#filt_iterator = page_iterator.search("Contents[?LastModified >= `datetime.datetime(2018, 12, 11, 8, 5, 37, tzinfo=tzutc())`].Key")
#for key_data in filt_iterator:
# print(key_data)
#print(max(enumerate(page_iterator))[1])
#bucket = conn.list_objects(Bucket='noaa-nexrad-level2')['Contents']
#bucket = [obj['Key'] for obj in sorted(bucket, key=get_last_modified)]
#for obj in bucket:
# print(obj['Key'])