From a57022deb88ca0216b01791f4325d4aace6de8f3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 11 Apr 2014 01:52:12 -0400 Subject: propellor spin --- Propellor/Exception.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Propellor') diff --git a/Propellor/Exception.hs b/Propellor/Exception.hs index bd9212a8..f6fd15f1 100644 --- a/Propellor/Exception.hs +++ b/Propellor/Exception.hs @@ -4,13 +4,15 @@ module Propellor.Exception where import qualified "MonadCatchIO-transformers" Control.Monad.CatchIO as M import Control.Exception -import Control.Applicative import Propellor.Types +import Propellor.Message -- | Catches IO exceptions and returns FailedChange. catchPropellor :: Propellor Result -> Propellor Result -catchPropellor a = either (\_ -> FailedChange) id <$> tryPropellor a +catchPropellor a = either err return =<< tryPropellor a + where + err e = warningMessage (show e) >> return FailedChange tryPropellor :: Propellor a -> Propellor (Either IOException a) tryPropellor = M.try -- cgit v1.3-2-g0d8e From ba6e87cde965dface863742cf84a59782ae29aee Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 11 Apr 2014 01:53:37 -0400 Subject: propellor spin --- Propellor/Property/Scheduled.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Propellor') diff --git a/Propellor/Property/Scheduled.hs b/Propellor/Property/Scheduled.hs index 8341765e..769a3931 100644 --- a/Propellor/Property/Scheduled.hs +++ b/Propellor/Property/Scheduled.hs @@ -61,7 +61,7 @@ setLastChecked time desc = do readLastChecked :: IO (M.Map Desc LocalTime) readLastChecked = fromMaybe M.empty <$> catchDefaultIO Nothing go where - go = readish <$> readFile lastCheckedFile + go = readish <$> readFileStrict lastCheckedFile writeLastChecked :: M.Map Desc LocalTime -> IO () writeLastChecked = writeFile lastCheckedFile . show -- cgit v1.3-2-g0d8e From be01532282bdca11e6fc97114206e44872d16eea Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 11 Apr 2014 02:03:51 -0400 Subject: foo --- Propellor/PrivData.hs | 3 +++ Propellor/Property.hs | 1 + 2 files changed, 4 insertions(+) (limited to 'Propellor') diff --git a/Propellor/PrivData.hs b/Propellor/PrivData.hs index 5adc9e94..c7af1aac 100644 --- a/Propellor/PrivData.hs +++ b/Propellor/PrivData.hs @@ -22,6 +22,9 @@ import Utility.Tmp import Utility.SafeCommand import Utility.Misc +-- | When the specified PrivDataField is available on the host Propellor +-- is provisioning, it provies the data to the action. Otherwise, it prints +-- a message to help the user make the necessary private data available. withPrivData :: PrivDataField -> (String -> Propellor Result) -> Propellor Result withPrivData field a = maybe missing a =<< liftIO (getPrivData field) where diff --git a/Propellor/Property.hs b/Propellor/Property.hs index 3a3c1cb1..83e19a73 100644 --- a/Propellor/Property.hs +++ b/Propellor/Property.hs @@ -105,6 +105,7 @@ host :: HostName -> Host host hn = Host [] (\_ -> newAttr hn) -- | Adds a property to a Host +-- -- Can add Properties, RevertableProperties, and AttrProperties (&) :: IsProp p => Host -> p -> Host (Host ps as) & p = Host (ps ++ [toProp p]) (getAttr p . as) -- cgit v1.3-2-g0d8e