Skip to content

Commit

Permalink
fix - Download da banda PAN falhava, corrompendo o arquivo. Otimizaçã…
Browse files Browse the repository at this point in the history
…o de imports. Bump para 0.7.3. Substituição da elipsis para pass.
  • Loading branch information
gabriel-russo committed Feb 20, 2024
1 parent 6f424d8 commit c93e119
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "cbers4asat"
version = "0.7.2"
version = "0.7.3"
description = "Biblioteca Python para realizar a busca e processamento de imagens dos satélites CBERS-04A e AMAZONIA-1"
authors = [
{ name = "Gabriel Russo", email = "[email protected]" }]
Expand Down
20 changes: 18 additions & 2 deletions src/cbers4asat/cbers4a/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
# -*- coding: utf-8 -*-

from datetime import datetime
import requests
from urllib3.util import Retry
from requests import Session
from requests.adapters import HTTPAdapter
from os.path import join


Expand Down Expand Up @@ -182,13 +184,27 @@ def url(self, asset):
"""
return self._feature["assets"][asset]["href"]

def download(self, asset, credential, outdir, session=requests.Session()):
def download(self, asset, credential, outdir, session=Session()):
"""
Download the asset.
"""
url = self.url(asset)
filename = url.split("/")[-1]
outfile = join(outdir, filename)

retries = Retry(
total=3,
connect=3,
read=3,
status=3,
other=3,
backoff_factor=1,
status_forcelist=[500, 501, 502, 503, 504],
allowed_methods={"GET"},
)

session.mount("http://", HTTPAdapter(max_retries=retries))

r = session.get(
url,
params={
Expand Down
4 changes: 2 additions & 2 deletions src/cbers4asat/cbers4asat.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def download(
outdir: str = getcwd(),
with_folder: bool = False,
):
...
pass

@overload
def download(
Expand All @@ -213,7 +213,7 @@ def download(
outdir: str = getcwd(),
with_folder: bool = False,
):
...
pass

def download(
self,
Expand Down

0 comments on commit c93e119

Please sign in to comment.