Py.Cafe

bmorris3/

debug-solara-ftp

debugging with Maarten

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import solara
from astropy.io import fits
from urllib.request import urlopen, urlretrieve
from tempfile import TemporaryFile

@solara.component
def Page():

    url = 'ftp://phoenix.astro.physik.uni-goettingen.de/v2.0/HiResFITS/WAVE_PHOENIX-ACES-AGSS-COND-2011.fits'

    with urlopen(url) as retr:
        print('HTTP status:', retr.status)

        try: 
            print(fits.open(retr.fp, mode='readonly'))
        except Exception as e:
            print(f'ERROR: urlopen fails with:\n\n{e}\n\n')


    try:
        path, headers = urlretrieve(url)
        stat = os.stat(path)
        print(fits.info(path))
    except Exception as e:
        
        print(f'ERROR: urlretrieve fails with:\n\n{e}\n')
        print(f"file size of the result = {stat.st_size} b\n\n")