Alon Bar-Lev has uploaded a new change for review.

Change subject: packaging: setup: add branding support
......................................................................

packaging: setup: add branding support

Change-Id: I2ad442ed67d7c89625791961285adfc66c008358
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M packaging/branding/ovirt.brand/messages.properties
A packaging/setup/ovirt_engine_setup/branding.py
M packaging/setup/ovirt_engine_setup/constants.py
3 files changed, 95 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/41/16641/1

diff --git a/packaging/branding/ovirt.brand/messages.properties 
b/packaging/branding/ovirt.brand/messages.properties
index fb8f435..3e69a93 100644
--- a/packaging/branding/ovirt.brand/messages.properties
+++ b/packaging/branding/ovirt.brand/messages.properties
@@ -30,3 +30,8 @@
 obrand.webadmin.doc=ENGINE Web Admin Documentation
 # The text at the top of the main user page.
 obrand.webadmin.main_header_label=
+
+# Setup specific messages
+
+obrand.setup.package_name = 'ovirt-engine'
+obrand.setup.upgrade_yum_group = 'ovirt-engine-3.3'
diff --git a/packaging/setup/ovirt_engine_setup/branding.py 
b/packaging/setup/ovirt_engine_setup/branding.py
new file mode 100644
index 0000000..f6ab4a6
--- /dev/null
+++ b/packaging/setup/ovirt_engine_setup/branding.py
@@ -0,0 +1,87 @@
+#
+# ovirt-engine-setup -- ovirt engine setup
+# Copyright (C) 2013 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+import os
+import locale
+import glob
+import StringIO
+import configparser
+
+
+from otopi import base
+from otopi import util
+
+
+from . import config
+
+
[email protected]
+class Branding(base.Base):
+
+    def _readProperties(self, name):
+        with open(name, 'r') as f:
+            config = configparser.ConfigParser()
+            config.optionxform = str
+            config.readfp(StringIO.StringIO('[root]\n' + f.read()))
+            return config
+
+    def __init__(self, application='setup'):
+        super(Branding, self).__init__()
+
+        self._application = application
+        self._messages = {}
+
+        for branding in sorted(
+            glob.glob(
+                os.path.join(
+                    config.ENGINE_SYSCONFDIR,
+                    'branding',
+                    '*.brand',
+                    'branding.properties'
+                )
+            )
+        ):
+            brnd = self._readProperties(branding)
+            if brnd.has_option('root', 'messages'):
+                msgfname = os.path.join(
+                    os.path.dirname(branding),
+                    brnd.get('root', 'messages')
+                )
+                for f in (
+                    msgfname,
+                    msgfname.replace(
+                        '.properties',
+                        '_%s.properties' % locale.getdefaultlocale()[0]
+                    )
+                ):
+                    if os.path.exists(f):
+                        msgs = self._readProperties(f)
+                        for m in msgs.options('root'):
+                            self._messages[m] = msgs.get('root', m)
+
+    def getMessage(self, message):
+        k = 'obrand.%s.%s' % (self._application, message)
+        if k in self._messages:
+            return self._messages[k]
+        return self._messages.get('obrand.common.%s' % message, '')
+
+
+branding = Branding()
+
+
+# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/packaging/setup/ovirt_engine_setup/constants.py 
b/packaging/setup/ovirt_engine_setup/constants.py
index 35099e5..fd97999 100644
--- a/packaging/setup/ovirt_engine_setup/constants.py
+++ b/packaging/setup/ovirt_engine_setup/constants.py
@@ -29,6 +29,7 @@
 
 
 from . import config
+from branding import branding
 
 
 def osetupattrsclass(o):
@@ -529,9 +530,9 @@
 
     ENGINE_URI = '/ovirt-engine'
 
-    ENGINE_PACKAGE_NAME = 'ovirt-engine'
+    ENGINE_PACKAGE_NAME = branding.getMessage('package_name')
     ENGINE_PACKAGE_SETUP_NAME = '%s-setup' % ENGINE_PACKAGE_NAME
-    UPGRADE_YUM_GROUP = 'ovirt-engine-3.3'
+    UPGRADE_YUM_GROUP = branding.getMessage('upgrade_yum_group')
 
     @classproperty
     def RPM_LOCK_LIST(self):


-- 
To view, visit http://gerrit.ovirt.org/16641
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2ad442ed67d7c89625791961285adfc66c008358
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to