summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/Monitors
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@gmail.com>2014-02-05 02:34:15 -0500
committerBen Boeckel <mathstuf@gmail.com>2014-02-05 02:52:28 -0500
commitbfc7362182f75cba63866cc915f9dbe62ebe9a42 (patch)
tree6ba62bc8727e6d3cb7e38cba7456aa4b2bfa0824 /src/Plugins/Monitors
parent7a4219abe3b4885820bece194c7f125274a711c6 (diff)
downloadxmobar-bfc7362182f75cba63866cc915f9dbe62ebe9a42.tar.gz
xmobar-bfc7362182f75cba63866cc915f9dbe62ebe9a42.tar.bz2
Drop curl dependency for the HTTP module
Diffstat (limited to 'src/Plugins/Monitors')
-rw-r--r--src/Plugins/Monitors/Weather.hs24
1 files 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 "<Could not retrieve data>"
formatWeather :: [WeatherInfo] -> Monitor String
formatWeather [(WI st ss y m d h w v sk tC tF dp r p)] =