src/oceandata/gdp.py
def download(url="ftp://ftp.aoml.noaa.gov/phod/pub/buoydata/"):
    """Download tsv file from NOOA's website using ftp"""
    lfn = filename = f"buoydata_{v1}_{v2}.dat.gz"
    ftp = open_ftp_session(url=url)

    local_filename = os.path.join(DATADIR, filename)
    if not filename in ftp.nlst():
        print(ftp.nlst())
        raise ftplib.Error("'%s' is not the ftp server" % lfn)
    with open(local_filename, 'wb') as lfh:
        ftp.voidcmd('TYPE I')
        length = ftp.size(lfn)
        short_lfn = lfn if len(lfn)<18 else lfn[:4] + "..." + lfn[-13:]
        with click.progressbar(length=length, label=short_lfn) as bar:
            def file_write(data):
                lfh.write(data) 
                bar.update(len(data))
            try:
                ftp.retrbinary("RETR %s" % lfn, file_write)
            except ftplib.error_perm as err:
                os.unlink(local_filename)
                raise IOError(err)
        ftp.quit()
Download tsv file from NOOA's website using ftp
Download tsv file from NOOA's website using ftp
Download tsv file from NOOA ' s website using ftp
def download(url="ftp://ftp.aoml.noaa.gov/phod/pub/buoydata/"):
    lfn = filename = f"buoydata_{v1}_{v2}.dat.gz"
    ftp = open_ftp_session(url=url)
    local_filename = os.path.join(DATADIR, filename)
    if not filename in ftp.nlst():
        print(ftp.nlst())
        raise ftplib.Error("'%s' is not the ftp server" % lfn)
    with open(local_filename, 'wb') as lfh:
        ftp.voidcmd('TYPE I')
        length = ftp.size(lfn)
        short_lfn = lfn if len(lfn)<18 else lfn[:4] + "..." + lfn[-13:]
        with click.progressbar(length=length, label=short_lfn) as bar:
            def file_write(data):
                lfh.write(data) 
                bar.update(len(data))
            try:
                ftp.retrbinary("RETR %s" % lfn, file_write)
            except ftplib.error_perm as err:
                os.unlink(local_filename)
                raise IOError(err)
        ftp.quit()
def download ( url = "ftp://ftp.aoml.noaa.gov/phod/pub/buoydata/" ) : lfn = filename = f"buoydata_{v1}_{v2}.dat.gz" ftp = open_ftp_session ( url = url ) local_filename = os . path . join ( DATADIR , filename ) if not filename in ftp . nlst ( ) : print ( ftp . nlst ( ) ) raise ftplib . Error ( "'%s' is not the ftp server" % lfn ) with open ( local_filename , 'wb' ) as lfh : ftp . voidcmd ( 'TYPE I' ) length = ftp . size ( lfn ) short_lfn = lfn if len ( lfn ) < 18 else lfn [ : 4 ] + "..." + lfn [ - 13 : ] with click . progressbar ( length = length , label = short_lfn ) as bar : def file_write ( data ) : lfh . write ( data ) bar . update ( len ( data ) ) try : ftp . retrbinary ( "RETR %s" % lfn , file_write ) except ftplib . error_perm as err : os . unlink ( local_filename ) raise IOError ( err ) ftp . quit ( )
Download tsv file from NOOA's website using ftp
Download tsv file from NOOA ' s website using ftp
"""Download tsv file from NOOA's website using ftp"""
url