Changeset 74:1aba83981490 for src/mlx


Ignore:
Timestamp:
04/11/12 15:51:57 (13 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Modified METAR retrieval to work with the new website

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/web.py

    r67 r74  
    458458    def run(self):
    459459        """Perform the retrieval opf the METARs."""
    460         tm = time.gmtime()
    461         url = "http://weather.noaa.gov/pub/data/observations/metar/cycles/%02dZ.TXT" % \
    462               (tm.tm_hour,)
     460        url = "http://www.aviationweather.gov/adds/dataserver_current/httpparam?"
     461        data = urllib.urlencode([ ("dataSource" , "metars"),
     462                                  ("requestType",  "retrieve"),
     463                                  ("format", "csv"),
     464                                  ("stationString", " ".join(self._airports)),
     465                                  ("hoursBeforeNow", "24"),
     466                                  ("mostRecentForEachStation", "constraint")])
     467        url += data
    463468        f = urllib2.urlopen(url)
    464469        try:
     
    468473                if len(line)>5 and line[4]==' ':
    469474                    icao = line[0:4]
    470                     if icao in self._airports:
    471                         result.metars[icao] = line.strip()
     475                    if icao in self._airports:                       
     476                        result.metars[icao] = line.strip().split(",")[0]
    472477        finally:
    473478            f.close()
Note: See TracChangeset for help on using the changeset viewer.