MrChebur / usgs-machine-to-machine-API

Simple Python wrapper of the USGS/EROS Inventory Service Machine-to-Machine API as described in the documents at https://m2m.cr.usgs.gov/api/docs/json/
GNU General Public License v3.0
18 stars 7 forks source link

Update otherMethods.py #7

Closed AkshathRaghav closed 1 year ago

AkshathRaghav commented 1 year ago

Hi @MrChebur! Been using your python wrapper for a research project where we are gathering USGS data.

Noticed that when I try downloading data from any "BUNDLE" product under any dataset (eg, landsat_ba_tile_c2), the requests.head(url, allow_redirects=True).headers [Line 67] in the otherMethods.py file returns a 400 Error. This seems to be an issue from the AWS side, and we get an error message within the JSON object.

To solve this, I am currently checking whether the requested product is a BUNDLE product, and just find the name of the file from the url within the class and save it based on that.

The changes are in the download() and _download() functions.

These changes seem to be a more of a quick fix since the wrapper only faces issues with .tar files. Hopefully, they are acceptable to you.

MrChebur commented 1 year ago

@AkshathRaghav I thank you for your Pull Request. The main purpose of this repository is to create a Python wrapper for the USGS API. I would like to point out that the code in the otherMethods.py file is more of a supplement to the main code - the USGS API wrapper. Writing the code for convenient data loading is a separate task that requires considerable effort and time.

AkshathRaghav commented 1 year ago

@MrChebur Thank you for replying! I've resolved the changes you wanted. I found your code really helpful and gave me the flexibility to do what I wanted, so I hoped this small change might help others trying to do the same as me.