From fd17a73ec470807adf1b21b6e328642f1a912aee Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sun, 11 Aug 2013 19:18:44 +0300 Subject: Plugins.Monitors.Weather: fix parsing of unknown station name reported by thunderrd Signed-off-by: Sergei Trofimovich --- src/Plugins/Monitors/Weather.hs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/Plugins') diff --git a/src/Plugins/Monitors/Weather.hs b/src/Plugins/Monitors/Weather.hs index 1277438..6c685ec 100644 --- a/src/Plugins/Monitors/Weather.hs +++ b/src/Plugins/Monitors/Weather.hs @@ -89,11 +89,28 @@ pPressure = do manyTill anyChar $ char '(' skipRestOfLine return $ read s +{- + example of 'http://weather.noaa.gov/pub/data/observations/metar/decoded/VTUD.TXT': + Station name not available + Aug 11, 2013 - 10:00 AM EDT / 2013.08.11 1400 UTC + Wind: from the N (350 degrees) at 1 MPH (1 KT):0 + Visibility: 4 mile(s):0 + Sky conditions: mostly clear + Temperature: 77 F (25 C) + Dew Point: 73 F (23 C) + Relative Humidity: 88% + Pressure (altimeter): 29.77 in. Hg (1008 hPa) + ob: VTUD 111400Z 35001KT 8000 FEW030 25/23 Q1008 A2977 INFO R RWY30 + cycle: 14 +-} parseData :: Parser [WeatherInfo] parseData = - do st <- getAllBut "," - space - ss <- getAllBut "(" + do (st, ss) <- try (string "Station name not available" >> return ("??", "??")) <|> + (do st <- getAllBut "," + space + ss <- getAllBut "(" + return (st, ss) + ) skipRestOfLine >> getAllBut "/" (y,m,d,h) <- pTime w <- getAfterString "Wind: " -- cgit v1.2.3