summaryrefslogtreecommitdiff
path: root/Propellor/CmdLine.hs
diff options
context:
space:
mode:
authorJoey Hess2014-03-31 18:44:10 -0400
committerJoey Hess2014-03-31 18:44:10 -0400
commit45a453a87efb04f3777c7b153da3f391fc0513fb (patch)
tree0fa2a8f2bea28a63222ff173ceb15b86d93c3bb2 /Propellor/CmdLine.hs
parent93d772a60af1657c8f13c1266b1d1c2ce267db30 (diff)
propellor spin
Diffstat (limited to 'Propellor/CmdLine.hs')
-rw-r--r--Propellor/CmdLine.hs14
1 files changed, 9 insertions, 5 deletions
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