From 45a453a87efb04f3777c7b153da3f391fc0513fb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 31 Mar 2014 18:44:10 -0400 Subject: propellor spin --- Propellor/CmdLine.hs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'Propellor') diff --git a/Propellor/CmdLine.hs b/Propellor/CmdLine.hs index 5a794ada..08d95249 100644 --- a/Propellor/CmdLine.hs +++ b/Propellor/CmdLine.hs @@ -166,9 +166,7 @@ spin host = do showremote s = putStrLn s senddata toh f marker s = void $ actionMessage ("Sending " ++ f ++ " (" ++ show (length s) ++ " bytes) to " ++ host) $ do - hFlush stdout - hPutStrLn toh $ toMarked marker s - hFlush toh + sendMarked toh marker s return True sendGitClone :: HostName -> String -> IO () @@ -206,6 +204,13 @@ privDataMarker = "PRIVDATA " toMarked :: Marker -> String -> String toMarked marker = intercalate "\n" . map (marker ++) . lines +sendMarked :: Handle -> Marker -> String -> IO () +sendMarked h marker s = do + -- Prefix string with newline because sometimes a + -- incomplete line is output. + hPutStrLn h ("\n" ++ toMarked marker s) + hFlush h + fromMarked :: Marker -> Marked -> Maybe String fromMarked marker s | null matches = Nothing @@ -217,8 +222,7 @@ fromMarked marker s boot :: [Property] -> IO () boot props = do - putStrLn $ toMarked statusMarker $ show Ready - hFlush stdout + sendMarked stdout statusMarker $ show Ready reply <- hGetContentsStrict stdin makePrivDataDir -- cgit v1.2.3