LGTM, thanks.

On Mon, Oct 7, 2013 at 4:37 PM, Jose A. Lopes <[email protected]> wrote:

> Add Luxi related constants to the Haskell to Python constant
> generation.  A new Haskell type is added 'Ganeti.Types.PythonChar' to
> wrap the Python character type.
>
> Signed-off-by: Jose A. Lopes <[email protected]>
> ---
>  lib/constants.py            | 13 +++++--------
>  src/Ganeti/ConstantUtils.hs |  8 ++++++++
>  src/Ganeti/HsConstants.hs   | 21 ++++++++++++++++++++-
>  3 files changed, 33 insertions(+), 9 deletions(-)
>
> diff --git a/lib/constants.py b/lib/constants.py
> index ca99f07..1d5e19d 100644
> --- a/lib/constants.py
> +++ b/lib/constants.py
> @@ -169,14 +169,11 @@ DEV_CONSOLE = _constants.DEV_CONSOLE
>
>  PROC_MOUNTS = "/proc/mounts"
>
> -# Local UniX Interface related constants
> -LUXI_EOM = chr(3)
> -LUXI_VERSION = CONFIG_VERSION
> -#: Environment variable for the luxi override socket
> -LUXI_OVERRIDE = "FORCE_LUXI_SOCKET"
> -LUXI_OVERRIDE_MASTER = "master"
> -LUXI_OVERRIDE_QUERY = "query"
> -
> +LUXI_EOM = _constants.LUXI_EOM
> +LUXI_VERSION = _constants.LUXI_VERSION
> +LUXI_OVERRIDE = _constants.LUXI_OVERRIDE
> +LUXI_OVERRIDE_MASTER = _constants.LUXI_OVERRIDE_MASTER
> +LUXI_OVERRIDE_QUERY = _constants.LUXI_OVERRIDE_QUERY
>  # one of "no", "yes", "only"
>  SYSLOG_USAGE = _constants.SYSLOG_USAGE
>  SYSLOG_NO = _constants.SYSLOG_NO
> diff --git a/src/Ganeti/ConstantUtils.hs b/src/Ganeti/ConstantUtils.hs
> index 62285dc..f6ea748 100644
> --- a/src/Ganeti/ConstantUtils.hs
> +++ b/src/Ganeti/ConstantUtils.hs
> @@ -28,12 +28,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor,
> Boston, MA
>  -}
>  module Ganeti.ConstantUtils where
>
> +import Data.Char (ord)
>  import Data.Set (Set)
>  import qualified Data.Set as Set (fromList, toList)
>
>  import Ganeti.THH (PyValue(..))
>  import Ganeti.PyValueInstances ()
>
> +-- | PythonChar wraps a Python 'char'
> +newtype PythonChar = PythonChar { unPythonChar :: Char }
> +  deriving (Show)
> +
> +instance PyValue PythonChar where
> +  showValue c = "chr(" ++ show (ord (unPythonChar c)) ++ ")"
> +
>  -- | FrozenSet wraps a Haskell 'Set'
>  --
>  -- See 'PyValue' instance for 'FrozenSet'.
> diff --git a/src/Ganeti/HsConstants.hs b/src/Ganeti/HsConstants.hs
> index 5e5b243..4bd9139 100644
> --- a/src/Ganeti/HsConstants.hs
> +++ b/src/Ganeti/HsConstants.hs
> @@ -41,7 +41,8 @@ import Data.Map (Map)
>  import qualified Data.Map as Map (fromList, keys, insert)
>
>  import AutoConf
> -import Ganeti.ConstantUtils (FrozenSet, Protocol(..), buildVersion)
> +import Ganeti.ConstantUtils (PythonChar(..), FrozenSet, Protocol(..),
> +                             buildVersion)
>  import qualified Ganeti.ConstantUtils as ConstantUtils
>  import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..),
>                         ExtraLogReason(..))
> @@ -341,6 +342,24 @@ extraLogreasonError = Runtime.daemonsExtraLogbase
> GanetiMond ErrorLog
>  devConsole :: String
>  devConsole = ConstantUtils.devConsole
>
> +-- * Luxi (Local UniX Interface) related constants
> +
> +luxiEom :: PythonChar
> +luxiEom = PythonChar '\x03'
> +
> +-- | Environment variable for the luxi override socket
> +luxiOverride :: String
> +luxiOverride = "FORCE_LUXI_SOCKET"
> +
> +luxiOverrideMaster :: String
> +luxiOverrideMaster = "master"
> +
> +luxiOverrideQuery :: String
> +luxiOverrideQuery = "query"
> +
> +luxiVersion :: Int
> +luxiVersion = configVersion
> +
>  -- * Syslog
>
>  syslogUsage :: String
> --
> 1.8.4
>
>


-- 
Thomas Thrainer | Software Engineer | [email protected] |

Google Germany GmbH
Dienerstr. 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores

Reply via email to