comparison src/core/sat_main.py @ 1375:3a20312d4012

core: if we are in dev version and it's possible, repository data are now checked and added to SàT version
author Goffi <goffi@goffi.org>
date Thu, 19 Mar 2015 19:47:01 +0100
parents 0befb14ecf62
children 28fd9e838f8f
comparison
equal deleted inserted replaced
1374:0befb14ecf62 1375:3a20312d4012
31 log = getLogger(__name__) 31 log = getLogger(__name__)
32 from sat.core.constants import Const as C 32 from sat.core.constants import Const as C
33 from sat.memory.memory import Memory 33 from sat.memory.memory import Memory
34 from sat.memory.crypto import PasswordHasher 34 from sat.memory.crypto import PasswordHasher
35 from sat.tools import trigger 35 from sat.tools import trigger
36 from sat.tools import utils
36 from sat.stdui import ui_contact_list, ui_profile_manager 37 from sat.stdui import ui_contact_list, ui_profile_manager
37 from glob import glob 38 from glob import glob
38 from uuid import uuid4 39 from uuid import uuid4
39 import sys 40 import sys
40 import os.path 41 import os.path
44 except ImportError: 45 except ImportError:
45 from ordereddict import OrderedDict 46 from ordereddict import OrderedDict
46 47
47 48
48 sat_id = 0 49 sat_id = 0
50 __version__ = C.APP_VERSION
49 51
50 52
51 def sat_next_id(): 53 def sat_next_id():
52 global sat_id 54 global sat_id
53 sat_id += 1 55 sat_id += 1
55 57
56 58
57 class SAT(service.Service): 59 class SAT(service.Service):
58 60
59 @property 61 @property
60 def __version__(self): 62 def version(self):
63 """Return the short version of SàT"""
61 return C.APP_VERSION 64 return C.APP_VERSION
65
66 @property
67 def full_version(self):
68 """Return the full version of SàT (with extra data when in development mode)"""
69 version = self.version
70 if version[-1] == 'D':
71 # we are in debug version, we add extra data
72 try:
73 return self._version_cache
74 except AttributeError:
75 self._version_cache = u"{} ({})".format(version, utils.getRepositoryData())
76 return self._version_cache
77 else:
78 return version
62 79
63 def get_next_id(self): 80 def get_next_id(self):
64 return sat_next_id() 81 return sat_next_id()
65 82
66 def __init__(self): 83 def __init__(self):
78 self.bridge = DBusBridge() 95 self.bridge = DBusBridge()
79 except exceptions.BridgeInitError: 96 except exceptions.BridgeInitError:
80 log.error(u"Bridge can't be initialised, can't start SàT core") 97 log.error(u"Bridge can't be initialised, can't start SàT core")
81 sys.exit(1) 98 sys.exit(1)
82 self.bridge.register("getReady", lambda: self._initialised) 99 self.bridge.register("getReady", lambda: self._initialised)
83 self.bridge.register("getVersion", lambda: C.APP_VERSION) 100 self.bridge.register("getVersion", lambda: self.full_version)
84 self.bridge.register("getProfileName", self.memory.getProfileName) 101 self.bridge.register("getProfileName", self.memory.getProfileName)
85 self.bridge.register("getProfilesList", self.memory.getProfilesList) 102 self.bridge.register("getProfilesList", self.memory.getProfilesList)
86 self.bridge.register("getEntityData", lambda jid_, keys, profile: self.memory.getEntityData(jid.JID(jid_), keys, profile)) 103 self.bridge.register("getEntityData", lambda jid_, keys, profile: self.memory.getEntityData(jid.JID(jid_), keys, profile))
87 self.bridge.register("getEntitiesData", self.memory._getEntitiesData) 104 self.bridge.register("getEntitiesData", self.memory._getEntitiesData)
88 self.bridge.register("asyncCreateProfile", self.memory.asyncCreateProfile) 105 self.bridge.register("asyncCreateProfile", self.memory.asyncCreateProfile)
251 268
252 current.fallBack = xmpp.SatFallbackHandler(self) 269 current.fallBack = xmpp.SatFallbackHandler(self)
253 current.fallBack.setHandlerParent(current) 270 current.fallBack.setHandlerParent(current)
254 271
255 current.versionHandler = xmpp.SatVersionHandler(C.APP_NAME_FULL, 272 current.versionHandler = xmpp.SatVersionHandler(C.APP_NAME_FULL,
256 C.APP_VERSION) 273 self.full_version)
257 current.versionHandler.setHandlerParent(current) 274 current.versionHandler.setHandlerParent(current)
258 275
259 current.identityHandler = xmpp.SatIdentityHandler() 276 current.identityHandler = xmpp.SatIdentityHandler()
260 current.identityHandler.setHandlerParent(current) 277 current.identityHandler.setHandlerParent(current)
261 278