propellor-5.3.6: property-based host configuration management in haskell

Safe HaskellNone
LanguageHaskell98

Propellor.Utilities

Description

Re-exports some of propellor's internal utility modules.

These are used in the implementation of propellor, including some of its properties. However, there is no API stability; any of these can change or be removed without a major version number increase.

Use outside propellor at your own risk.

Synopsis

Documentation

read :: Read a => String -> a Source #

head :: [a] -> a Source #

tail :: [a] -> [a] Source #

init :: [a] -> [a] Source #

last :: [a] -> a Source #

readish :: Read a => String -> Maybe a Source #

headMaybe :: [a] -> Maybe a Source #

lastMaybe :: [a] -> Maybe a Source #

beginning :: [a] -> [a] Source #

end :: [a] -> [a] Source #

data CreateProcess :: * #

Constructors

CreateProcess 

Fields

Instances

Eq CreateProcess 
Show CreateProcess 

Methods

showsPrec :: Int -> CreateProcess -> ShowS

show :: CreateProcess -> String

showList :: [CreateProcess] -> ShowS

data StdHandle Source #

Instances

Eq StdHandle Source # 

Methods

(==) :: StdHandle -> StdHandle -> Bool

(/=) :: StdHandle -> StdHandle -> Bool

readProcess :: FilePath -> [String] -> IO String Source #

Normally, when reading from a process, it does not need to be fed any standard input.

readProcessEnv :: FilePath -> [String] -> Maybe [(String, String)] -> IO String Source #

writeReadProcessEnv :: FilePath -> [String] -> Maybe [(String, String)] -> Maybe (Handle -> IO ()) -> Maybe (Handle -> IO ()) -> IO String Source #

Runs an action to write to a process on its stdin, returns its output, and also allows specifying the environment.

forceSuccessProcess :: CreateProcess -> ProcessHandle -> IO () Source #

Waits for a ProcessHandle, and throws an IOError if the process did not exit successfully.

forceSuccessProcess' :: CreateProcess -> ExitCode -> IO () Source #

checkSuccessProcess :: ProcessHandle -> IO Bool Source #

Waits for a ProcessHandle and returns True if it exited successfully. Note that using this with createProcessChecked will throw away the Bool, and is only useful to ignore the exit code of a process, while still waiting for it. -}

ignoreFailureProcess :: ProcessHandle -> IO Bool Source #

createProcessSuccess :: CreateProcessRunner Source #

Runs createProcess, then an action on its handles, and then forceSuccessProcess.

createProcessChecked :: (ProcessHandle -> IO b) -> CreateProcessRunner Source #

Runs createProcess, then an action on its handles, and then a checker action on its exit code, which must wait for the process.

createBackgroundProcess :: CreateProcessRunner Source #

Leaves the process running, suitable for lazy streaming. Note: Zombies will result, and must be waited on.

processTranscript :: String -> [String] -> Maybe String -> IO (String, Bool) Source #

Runs a process, optionally feeding it some input, and returns a transcript combining its stdout and stderr, and whether it succeeded or failed.

processTranscript' :: CreateProcess -> Maybe String -> IO (String, Bool) Source #

withHandle :: StdHandle -> CreateProcessRunner -> CreateProcess -> (Handle -> IO a) -> IO a Source #

Runs a CreateProcessRunner, on a CreateProcess structure, that is adjusted to pipe only from/to a single StdHandle, and passes the resulting Handle to an action.

withIOHandles :: CreateProcessRunner -> CreateProcess -> ((Handle, Handle) -> IO a) -> IO a Source #

Like withHandle, but passes (stdin, stdout) handles to the action.

withOEHandles :: CreateProcessRunner -> CreateProcess -> ((Handle, Handle) -> IO a) -> IO a Source #

Like withHandle, but passes (stdout, stderr) handles to the action.

withQuietOutput :: CreateProcessRunner -> CreateProcess -> IO () Source #

Forces the CreateProcessRunner to run quietly; both stdout and stderr are discarded.

feedWithQuietOutput :: CreateProcessRunner -> CreateProcess -> (Handle -> IO a) -> IO a Source #

Stdout and stderr are discarded, while the process is fed stdin from the handle.

createProcess :: CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) Source #

Wrapper around createProcess that does debug logging.

waitForProcess :: ProcessHandle -> IO ExitCode Source #

Wrapper around waitForProcess that does debug logging.

startInteractiveProcess :: FilePath -> [String] -> Maybe [(String, String)] -> IO (ProcessHandle, Handle, Handle) Source #

Starts an interactive process. Unlike runInteractiveProcess in System.Process, stderr is inherited.

stdinHandle :: HandleExtractor Source #

stdoutHandle :: HandleExtractor Source #

stderrHandle :: HandleExtractor Source #

ioHandles :: (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -> (Handle, Handle) Source #

processHandle :: (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -> ProcessHandle Source #

devNull :: FilePath Source #

giveup :: [Char] -> a Source #

catchBoolIO :: MonadCatch m => m Bool -> m Bool Source #

catchMaybeIO :: MonadCatch m => m a -> m (Maybe a) Source #

catchDefaultIO :: MonadCatch m => a -> m a -> m a Source #

catchMsgIO :: MonadCatch m => m a -> m (Either String a) Source #

catchIO :: MonadCatch m => m a -> (IOException -> m a) -> m a Source #

tryIO :: MonadCatch m => m a -> m (Either IOException a) Source #

bracketIO :: (MonadMask m, MonadIO m) => IO v -> (v -> IO b) -> (v -> m a) -> m a Source #

catchNonAsync :: MonadCatch m => m a -> (SomeException -> m a) -> m a Source #

tryNonAsync :: MonadCatch m => m a -> m (Either SomeException a) Source #

tryWhenExists :: MonadCatch m => m a -> m (Maybe a) Source #

catchIOErrorType :: MonadCatch m => IOErrorType -> (IOException -> m a) -> m a -> m a Source #

catchPermissionDenied :: MonadCatch m => (IOException -> m a) -> m a -> m a Source #

getEnv :: String -> IO (Maybe String) Source #

getEnvDefault :: String -> String -> IO String Source #

getEnvironment :: IO [(String, String)] Source #

setEnv :: String -> String -> Bool -> IO () Source #

unsetEnv :: String -> IO () Source #

addEntry :: Eq k => k -> v -> [(k, v)] -> [(k, v)] Source #

addEntries :: Eq k => [(k, v)] -> [(k, v)] -> [(k, v)] Source #

delEntry :: Eq k => k -> [(k, v)] -> [(k, v)] Source #

dirCruft :: FilePath -> Bool Source #

fsCruft :: FilePath -> Bool Source #

dirContents :: FilePath -> IO [FilePath] Source #

dirContentsRecursive :: FilePath -> IO [FilePath] Source #

dirContentsRecursiveSkipping :: (FilePath -> Bool) -> Bool -> FilePath -> IO [FilePath] Source #

dirTreeRecursiveSkipping :: (FilePath -> Bool) -> FilePath -> IO [FilePath] Source #

moveFile :: FilePath -> FilePath -> IO () Source #

nukeFile :: FilePath -> IO () Source #

data DirectoryHandle Source #

Constructors

DirectoryHandle IsOpen DirStream 

type IsOpen = MVar () Source #

readDirectory :: DirectoryHandle -> IO (Maybe FilePath) Source #

Reads the next entry from the handle. Once the end of the directory is reached, returns Nothing and automatically closes the handle.

isDirectoryEmpty :: FilePath -> IO Bool Source #

isUnpopulated :: FilePath -> IO Bool Source #

True if the directory does not exist or contains nothing. Ignores "lost+found" which can exist in an empty filesystem.

testDirectory :: FilePath -> (FilePath -> Bool) -> IO Bool Source #

Run test on entries found in directory, return False as soon as the test returns False, else return True. Throws exception if directory does not exist.

type Template = String Source #

viaTmp :: (MonadMask m, MonadIO m) => (FilePath -> String -> m ()) -> FilePath -> String -> m () Source #

withTmpFile :: (MonadIO m, MonadMask m) => Template -> (FilePath -> Handle -> m a) -> m a Source #

withTmpFileIn :: (MonadIO m, MonadMask m) => FilePath -> Template -> (FilePath -> Handle -> m a) -> m a Source #

withTmpDir :: (MonadMask m, MonadIO m) => Template -> (FilePath -> m a) -> m a Source #

withTmpDirIn :: (MonadMask m, MonadIO m) => FilePath -> Template -> (FilePath -> m a) -> m a Source #

removeTmpDir :: MonadIO m => FilePath -> m () Source #

relatedTemplate :: FilePath -> FilePath Source #

firstM :: Monad m => (a -> m Bool) -> [a] -> m (Maybe a) Source #

getM :: Monad m => (a -> m (Maybe b)) -> [a] -> m (Maybe b) Source #

anyM :: Monad m => (a -> m Bool) -> [a] -> m Bool Source #

allM :: Monad m => (a -> m Bool) -> [a] -> m Bool Source #

untilTrue :: Monad m => [a] -> (a -> m Bool) -> m Bool Source #

ifM :: Monad m => m Bool -> (m a, m a) -> m a Source #

(<||>) :: Monad m => m Bool -> m Bool -> m Bool infixr 2 Source #

(<&&>) :: Monad m => m Bool -> m Bool -> m Bool infixr 3 Source #

observe :: Monad m => (a -> m b) -> m a -> m a Source #

after :: Monad m => m b -> m a -> m a Source #

noop :: Monad m => m () Source #

hGetContentsStrict :: Handle -> IO String Source #

readFileStrict :: FilePath -> IO String Source #

separate :: (a -> Bool) -> [a] -> ([a], [a]) Source #

firstLine :: String -> String Source #

segment :: (a -> Bool) -> [a] -> [[a]] Source #

segmentDelim :: (a -> Bool) -> [a] -> [[a]] Source #

massReplace :: [(String, String)] -> String -> String Source #

hGetSomeString :: Handle -> Int -> IO String Source #

exitBool :: Bool -> IO a Source #