diff src/core/sat_main.py @ 923:e77948faaef3

core: removed default_config: - constants in core.default_config moved to core.constants - removed unused host.getConst and host.setConst - APP_NAME* used where it make sense
author Goffi <goffi@goffi.org>
date Sat, 22 Mar 2014 17:48:10 +0100
parents c897c8d321b3
children 5c78cefd233f
line wrap: on
line diff
--- a/src/core/sat_main.py	Sat Mar 22 15:34:05 2014 +0100
+++ b/src/core/sat_main.py	Sat Mar 22 17:48:10 2014 +0100
@@ -36,7 +36,6 @@
 import sys
 import os.path
 
-from sat.core.default_config import CONST
 from sat.core import xmpp
 from sat.core import exceptions
 from sat.core.constants import Const as C
@@ -85,32 +84,11 @@
 
     @property
     def __version__(self):
-        return self.getConst('client_version')
+        return C.APP_VERSION
 
     def get_next_id(self):
         return sat_next_id()
 
-    def getConst(self, name):
-        """Return a constant"""
-        try:
-            _const = os.environ['SAT_CONST_%s' % name]
-            if _const:
-                warning(_("Constant %(name)s overrided with [%(value)s]") % {'name': name, 'value': _const})
-                return _const
-        except KeyError:
-            pass
-        if name not in CONST:
-            error(_('Trying to access an undefined constant'))
-            raise Exception
-        return CONST[name]
-
-    def setConst(self, name, value):
-        """Save a constant"""
-        if name in CONST:
-            error(_('Trying to redefine a constant'))
-            raise Exception
-        CONST[name] = value
-
     def __init__(self):
         self._cb_map = {}  # map from callback_id to callbacks
         self._menus = {}  # dynamic menus. key: callback_id, value: menu data (dictionnary)
@@ -131,7 +109,7 @@
         except exceptions.BridgeInitError:
             print (u"Bridge can't be initialised, can't start SàT core") # reactor is not launched yet, so we can't use error log
             sys.exit(1)
-        self.bridge.register("getVersion", lambda: self.getConst('client_version'))
+        self.bridge.register("getVersion", lambda: C.APP_VERSION)
         self.bridge.register("getProfileName", self.memory.getProfileName)
         self.bridge.register("getProfilesList", self.memory.getProfilesList)
         self.bridge.register("getEntityData", lambda _jid, keys, profile: self.memory.getEntityData(jid.JID(_jid), keys, profile))
@@ -273,8 +251,8 @@
             current.fallBack = xmpp.SatFallbackHandler(self)
             current.fallBack.setHandlerParent(current)
 
-            current.versionHandler = xmpp.SatVersionHandler(self.getConst('client_name'),
-                                                            self.getConst('client_version'))
+            current.versionHandler = xmpp.SatVersionHandler(C.APP_NAME_FULL,
+                                                            C.APP_VERSION)
             current.versionHandler.setHandlerParent(current)
 
             current.identityHandler = xmpp.SatIdentityHandler()