Revision 9739b6b8 hspace.hs
b/hspace.hs | ||
---|---|---|
25 | 25 |
|
26 | 26 |
module Main (main) where |
27 | 27 |
|
28 |
import Data.Char (toUpper) |
|
28 |
import Data.Char (toUpper, isAlphaNum)
|
|
29 | 29 |
import Data.List |
30 | 30 |
import Data.Function |
31 | 31 |
import Data.Maybe (isJust, fromJust) |
... | ... | |
89 | 89 |
\cs -> printf "%.8f" (fromIntegral (Cluster.csImem cs) / |
90 | 90 |
Cluster.csTmem cs)) |
91 | 91 |
, ("DSK_FREE", printf "%d" . Cluster.csFdsk) |
92 |
, ("DSK_AVAIL", printf "%d ". Cluster.csAdsk)
|
|
92 |
, ("DSK_AVAIL", printf "%d". Cluster.csAdsk) |
|
93 | 93 |
, ("DSK_RESVD", |
94 | 94 |
\cs -> printf "%d" (Cluster.csFdsk cs - Cluster.csAdsk cs)) |
95 | 95 |
, ("DSK_INST", printf "%d" . Cluster.csIdsk) |
... | ... | |
187 | 187 |
-- this should be the final entry |
188 | 188 |
printKeys [("OK", "1")] |
189 | 189 |
|
190 |
-- | Ensure a value is quoted if needed |
|
191 |
ensureQuoted :: String -> String |
|
192 |
ensureQuoted v = if not (all (\c -> (isAlphaNum c || c == '.')) v) |
|
193 |
then '\'':v ++ "'" |
|
194 |
else v |
|
195 |
|
|
190 | 196 |
-- | Format a list of key/values as a shell fragment |
191 | 197 |
printKeys :: [(String, String)] -> IO () |
192 |
printKeys = mapM_ (\(k, v) -> printf "HTS_%s=%s\n" (map toUpper k) v) |
|
198 |
printKeys = mapM_ (\(k, v) -> |
|
199 |
printf "HTS_%s=%s\n" (map toUpper k) (ensureQuoted v)) |
|
193 | 200 |
|
194 | 201 |
printInstance :: Node.List -> Instance.Instance -> [String] |
195 | 202 |
printInstance nl i = [ Instance.name i |
Also available in: Unified diff