Mercurial > libervia-backend
comparison src/memory/memory.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 | ed9841e6d84a |
children | cbf4122baae7 |
comparison
equal
deleted
inserted
replaced
922:c897c8d321b3 | 923:e77948faaef3 |
---|---|
26 from logging import debug, info, warning, error | 26 from logging import debug, info, warning, error |
27 from twisted.internet import defer, reactor | 27 from twisted.internet import defer, reactor |
28 from twisted.words.protocols.jabber import jid | 28 from twisted.words.protocols.jabber import jid |
29 from sat.core import exceptions | 29 from sat.core import exceptions |
30 from sat.core.constants import Const as C | 30 from sat.core.constants import Const as C |
31 from sat.core.default_config import default_config | |
32 from sat.memory.sqlite import SqliteStorage | 31 from sat.memory.sqlite import SqliteStorage |
33 from sat.memory.persistent import PersistentDict | 32 from sat.memory.persistent import PersistentDict |
34 from sat.memory.params import Params | 33 from sat.memory.params import Params |
35 | 34 |
36 | 35 |
116 # /!\ an entity is not necessarily in roster | 115 # /!\ an entity is not necessarily in roster |
117 self.subscriptions = {} | 116 self.subscriptions = {} |
118 self.server_features = {} # used to store discovery's informations | 117 self.server_features = {} # used to store discovery's informations |
119 self.server_identities = {} | 118 self.server_identities = {} |
120 self.config = self.parseMainConf() | 119 self.config = self.parseMainConf() |
121 host.setConst('savefile_database', C.SAVEFILE_DATABASE) | 120 database_file = os.path.expanduser(os.path.join(self.getConfig('', 'local_dir'), C.SAVEFILE_DATABASE)) |
122 database_file = os.path.expanduser(self.getConfig('', 'local_dir') + | |
123 self.host.getConst('savefile_database')) | |
124 self.storage = SqliteStorage(database_file, host.__version__) | 121 self.storage = SqliteStorage(database_file, host.__version__) |
125 PersistentDict.storage = self.storage | 122 PersistentDict.storage = self.storage |
126 self.params = Params(host, self.storage) | 123 self.params = Params(host, self.storage) |
127 info(_("Loading default params template")) | 124 info(_("Loading default params template")) |
128 self.params.load_default_params() | 125 self.params.load_default_params() |
131 d.addCallback(lambda ignore: self.memory_data.load()) | 128 d.addCallback(lambda ignore: self.memory_data.load()) |
132 d.chainDeferred(self.initialized) | 129 d.chainDeferred(self.initialized) |
133 | 130 |
134 def parseMainConf(self): | 131 def parseMainConf(self): |
135 """look for main .ini configuration file, and parse it""" | 132 """look for main .ini configuration file, and parse it""" |
136 _config = SafeConfigParser(defaults=default_config) | 133 _config = SafeConfigParser(defaults=C.DEFAULT_CONFIG) |
137 try: | 134 try: |
138 _config.read(map(os.path.expanduser, ['/etc/sat.conf', '~/sat.conf', '~/.sat.conf', 'sat.conf', '.sat.conf'])) | 135 _config.read(map(os.path.expanduser, ['/etc/sat.conf', '~/sat.conf', '~/.sat.conf', 'sat.conf', '.sat.conf'])) |
139 except: | 136 except: |
140 error(_("Can't read main config !")) | 137 error(_("Can't read main config !")) |
141 | 138 |