src/oceandata/mapps.py
def download(url="https://doi.pangaea.de/10.1594/PANGAEA.874087",
            params={"format":"textfile"}, filename=None):
    """Download tsv file from Pangaea server"""
    filename = FILENAME if filename is None else filename
    local_filename = os.path.join(DATADIR, filename)
    try:
        r = requests.get(url, params=params, stream=True, timeout=2)
    except requests.ReadTimeout:
        warnings.warn("Connection to server timed out.")
        return False
    if r.ok:
        if local_filename is None:
            return r.text
        else:
            with open(local_filename, 'wb') as f:
                for chunk in r.iter_content(chunk_size=1024): 
                    if chunk:
                        f.write(chunk)
                        f.flush()
            return None
    else:
        raise IOError("Could not download file from server")
Download tsv file from Pangaea server
Download tsv file from Pangaea server
Download tsv file from Pangaea server
def download(url="https://doi.pangaea.de/10.1594/PANGAEA.874087",
            params={"format":"textfile"}, filename=None):
    filename = FILENAME if filename is None else filename
    local_filename = os.path.join(DATADIR, filename)
    try:
        r = requests.get(url, params=params, stream=True, timeout=2)
    except requests.ReadTimeout:
        warnings.warn("Connection to server timed out.")
        return False
    if r.ok:
        if local_filename is None:
            return r.text
        else:
            with open(local_filename, 'wb') as f:
                for chunk in r.iter_content(chunk_size=1024): 
                    if chunk:
                        f.write(chunk)
                        f.flush()
            return None
    else:
        raise IOError("Could not download file from server")
def download ( url = "https://doi.pangaea.de/10.1594/PANGAEA.874087" , params = { "format" : "textfile" } , filename = None ) : filename = FILENAME if filename is None else filename local_filename = os . path . join ( DATADIR , filename ) try : r = requests . get ( url , params = params , stream = True , timeout = 2 ) except requests . ReadTimeout : warnings . warn ( "Connection to server timed out." ) return False if r . ok : if local_filename is None : return r . text else : with open ( local_filename , 'wb' ) as f : for chunk in r . iter_content ( chunk_size = 1024 ) : if chunk : f . write ( chunk ) f . flush ( ) return None else : raise IOError ( "Could not download file from server" )
Download tsv file from Pangaea server
Download tsv file from Pangaea server
"""Download tsv file from Pangaea server"""
url
params
filename