From bfc7362182f75cba63866cc915f9dbe62ebe9a42 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 5 Feb 2014 02:34:15 -0500 Subject: Drop curl dependency for the HTTP module --- src/Plugins/Monitors/Weather.hs | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/Plugins/Monitors/Weather.hs b/src/Plugins/Monitors/Weather.hs index a008453..4030352 100644 --- a/src/Plugins/Monitors/Weather.hs +++ b/src/Plugins/Monitors/Weather.hs @@ -16,10 +16,7 @@ module Plugins.Monitors.Weather where import Plugins.Monitors.Common -import Control.Monad (when) -import System.Process -import System.Exit -import System.IO +import Control.Exception (catch, IOException) import Network.HTTP import Text.ParserCombinators.Parsec @@ -134,19 +131,12 @@ stationUrl :: String -> String stationUrl station = defUrl ++ station ++ ".TXT" getData :: String -> IO String -getData url= - do (i,o,e,p) <- runInteractiveCommand ("curl " ++ defUrl ++ url ++ ".TXT") - exit <- waitForProcess p - let closeHandles = do hClose o - hClose i - hClose e - case exit of - ExitSuccess -> do str <- hGetContents o - when (str == str) $ return () - closeHandles - return str - _ -> do closeHandles - return "Could not retrieve data" +getData station = do + let request = getRequest (stationUrl station) + result <- simpleHTTP request + catch (getResponseBody result) errHandler + where errHandler :: IOException -> IO String + errHandler _ = return "" formatWeather :: [WeatherInfo] -> Monitor String formatWeather [(WI st ss y m d h w v sk tC tF dp r p)] = -- cgit v1.2.3