[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Christmas Wish Lists
John C. Peterson writes:
>On Thu, Dec 02, 1999 at 03:08:51PM -0800, Jerome Kaidor wrote:
>> >
>> > With the holidays coming up, I thought it might be fun
>for people to
>> > post thier Christmas "wish lists". No, I don't mean that
>new GPS unit or
>> > whatever, I mean in terms of aviation software for Linux.
>[...snip...]
>> >
>> *** How about a standardized API for doing DUATS-type stuff,
>e.g., getting
>> weather reports and filing flight plans? I've seen at least
>one TCL script
>> for doing this, but DUATS alas changes their format
>occasionally - such
>> scripts are always out of date. Also, there are at least
>two different
>> DUATS services.
>>
>
>I've played some with the aviation weather observations and forecasts
>that NOAA/NWS provides over the web, and found them to be fairly easy
>to work with. I've already written some crude shell scripts that I
>run regularly out of my crontab. They fetch pages with "lynx -dump",
>and then extract the desired data with "gawk". Writing "robot
>software" to interface with DUATS will be a bit trickier since
>cookies are being used to identify who you are. (And no passwd
>security I might add, Jeez!)
>
> Any other Xmas wishes??? Only 9 days until Santa comes :^)
>
attached find a simple python script that will get
weather reports
I am sure we could easily interface with DUATS also
as python has a simple to use 'cookie' interface.
Cheers
Norman
#! /usr/bin/env python
"""
get_metar.py -- get verbose metar station report
i.e. for Paris-Aeroport Charles De Gaulle, France (LFPG)
python get_metar.py LFPG
or
python get_metar.py -d LFPG
to see trace messages of what is happening
"""
import sys
debugging = 0
####
def get_metar(metar_id, callback=sys.stdout.write):
from ftplib import FTP
ftp = FTP('weather.noaa.gov')
ftp.set_debuglevel(debugging)
ftp.login()
ftp.cwd('/data/observations/metar/decoded')
ftp.retrbinary('RETR ' + metar_id + '.TXT', callback)
ftp.quit()
####
# test program starts here
if __name__ == '__main__':
while sys.argv[1] == '-d':
debugging = debugging+1
del sys.argv[1]
get_metar(sys.argv[1])