Skip to content

Commit

Permalink
Merge pull request #56 from sat-utils/develop
Browse files Browse the repository at this point in the history
publish 0.3.3
  • Loading branch information
matthewhanson authored Jan 23, 2020
2 parents 1f94732 + 9830b76 commit 5d1c495
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [v0.3.2] - 2020-01-022
## [v0.3.3] - 2020-01-23

### Fixed
- Spelling of requester pays (was requestor)

## [v0.3.2] - 2020-01-22

### Changed
- sat-stac now compatible with Python3 versions < 3.6 ()
Expand Down Expand Up @@ -74,6 +79,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
Initial Release

[Unreleased]: https://github.com/sat-utils/sat-stac/compare/master...develop
[v0.3.3]: https://github.com/sat-utils/sat-stac/compare/0.3.2...v0.3.3
[v0.3.2]: https://github.com/sat-utils/sat-stac/compare/0.3.1...v0.3.2
[v0.3.1]: https://github.com/sat-utils/sat-stac/compare/0.3.0...v0.3.1
[v0.3.0]: https://github.com/sat-utils/sat-stac/compare/0.2.0...v0.3.0
Expand Down
4 changes: 2 additions & 2 deletions satstac/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def download_assets(self, keys=None, **kwargs):
filenames.append(self.download(key, **kwargs))
return filenames

def download(self, key, overwrite=False, path='', filename='${id}', requestor_pays=False):
def download(self, key, overwrite=False, path='', filename='${id}', requester_pays=False):
""" Download this key (e.g., a band, or metadata file) from the scene """
asset = self.asset(key)
if asset is None:
Expand All @@ -148,7 +148,7 @@ def download(self, key, overwrite=False, path='', filename='${id}', requestor_pa
ext = os.path.splitext(asset['href'])[1]
fout = os.path.join(_path, fname + '_' + key + ext)
if not os.path.exists(fout) or overwrite:
_filename = utils.download_file(asset['href'], filename=fout, requestor_pays=requestor_pays)
_filename = utils.download_file(asset['href'], filename=fout, requester_pays=requester_pays)
else:
_filename = fout
except Exception as e:
Expand Down
8 changes: 4 additions & 4 deletions satstac/itemcollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ def summary(self, params=[]):
txt += ''.join(['{:<25} '.format(s.substitute('${%s}' % p)) for p in params]) + '\n'
return txt

def calendar(self):
def calendar(self, group='platform'):
""" Get calendar for dates """
date_labels = {}
for d in self.dates():
sensors = self.properties('eo:platform', d)
if len(sensors) > 1:
groups = self.properties(group, d)
if len(groups) > 1:
date_labels[d] = 'Multiple'
else:
date_labels[d] = sensors[0]
date_labels[d] = groups[0]
return terminal_calendar(date_labels)

def save(self, filename):
Expand Down
8 changes: 4 additions & 4 deletions satstac/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ def dict_merge(dct, merge_dct, add_keys=True):
return dct


def download_file(url, filename=None, requestor_pays=False):
def download_file(url, filename=None, requester_pays=False):
""" Download a file as filename """
filename = os.path.basename(url) if filename is None else filename
logger.info('Downloading %s as %s' % (url, filename))
headers = {}
# check if on s3, if so try to sign it
if 's3.amazonaws.com' in url:
signed_url, signed_headers = get_s3_signed_url(url, requestor_pays=requestor_pays)
signed_url, signed_headers = get_s3_signed_url(url, requester_pays=requester_pays)
resp = requests.get(signed_url, headers=signed_headers, stream=True)
if resp.status_code != 200:
resp = requests.get(url, headers=headers, stream=True)
Expand Down Expand Up @@ -98,7 +98,7 @@ def splitall(path):
return allparts


def get_s3_signed_url(url, rtype='GET', public=False, requestor_pays=False, content_type=None):
def get_s3_signed_url(url, rtype='GET', public=False, requester_pays=False, content_type=None):
access_key = os.environ.get('AWS_BUCKET_ACCESS_KEY_ID', os.environ.get('AWS_ACCESS_KEY_ID'))
secret_key = os.environ.get('AWS_BUCKET_SECRET_ACCESS_KEY', os.environ.get('AWS_SECRET_ACCESS_KEY'))
region = os.environ.get('AWS_BUCKET_REGION', os.environ.get('AWS_REGION', 'eu-central-1'))
Expand Down Expand Up @@ -142,7 +142,7 @@ def getSignatureKey(key, dateStamp, regionName, serviceName):
'x-amz-content-sha256': payload_hash,
'x-amz-date': amzdate
}
if requestor_pays:
if requester_pays:
headers['x-amz-request-payer'] = 'requester'
if public:
headers['x-amz-acl'] = 'public-read'
Expand Down
2 changes: 1 addition & 1 deletion satstac/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.3.2'
__version__ = '0.3.3'

0 comments on commit 5d1c495

Please sign in to comment.