Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

develop into main #70

Merged
merged 8 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion maap/Result.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,24 @@ def _getHttpData(self, url, overwrite, dest):

return dest

def getDownloadUrl(self):
def getDownloadUrl(self, s3=True):
"""
Get granule download url
:param s3: True returns the s3 url, False the http url
:return:
"""
return self.getS3Url() if s3 else self.getHttpUrl()

def getHttpUrl(self):
"""
Get granule http url
:return:
"""
return self._fallback

def getS3Url(self):
"""
Get granule s3 url
:return:
"""
return self._location
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
]
_description = 'maapPy Python API'
_download_url = ''
_requirements = ["backoff", "boto3", "ConfigParser", "ipython", "mapboxgl", "moto", "mypy_boto3_s3", "pytest",
_requirements = ["backoff", "boto3==1.33.13", "ConfigParser", "ipython==8.12.0", "mapboxgl", "moto", "mypy_boto3_s3", "pytest",
"PyYAML", "requests", "responses", "setuptools"]
_keywords = ['dataset', 'granule', 'nasa', 'MAAP', 'CMR']
_license = 'Apache License, Version 2.0'
Expand Down
9 changes: 9 additions & 0 deletions test/test_CMR.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,12 @@ def test_searchGranuleWithWildcards(self):
readable_granule_name='*185*')
self.assertTrue('concept-id' in results[0].keys())

def test_getUrl(self):
results = self.maap.searchGranule(page_num="1", concept_id="C1214470488-ASF", sort_key="-start_date", limit=1)

url = results[0].getHttpUrl()
self.assertTrue(url.startswith("http"))

url = results[0].getS3Url()
self.assertTrue(url.startswith("s3"))