comparison src/memory/memory.py @ 1859:ac2ac7fe8a9b

core (memory, config): moved parseMainConf to tools/config so it can be used by frontends too
author Goffi <goffi@goffi.org>
date Mon, 29 Feb 2016 16:13:47 +0100
parents d17772b0fe22
children 2daf7b4c6756
comparison
equal deleted inserted replaced
1858:06e13ae616cf 1859:ac2ac7fe8a9b
234 self._key_signals = set() # key which need a signal to frontends when updated 234 self._key_signals = set() # key which need a signal to frontends when updated
235 self.subscriptions = {} 235 self.subscriptions = {}
236 self.auth_sessions = PasswordSessions() # remember the authenticated profiles 236 self.auth_sessions = PasswordSessions() # remember the authenticated profiles
237 self.disco = Discovery(host) 237 self.disco = Discovery(host)
238 fixLocalDir(False) # XXX: tmp update code, will be removed in the future 238 fixLocalDir(False) # XXX: tmp update code, will be removed in the future
239 self.config = self.parseMainConf() 239 self.config = tools_config.parseMainConf()
240 database_file = os.path.expanduser(os.path.join(self.getConfig('', 'local_dir'), C.SAVEFILE_DATABASE)) 240 database_file = os.path.expanduser(os.path.join(self.getConfig('', 'local_dir'), C.SAVEFILE_DATABASE))
241 self.storage = SqliteStorage(database_file, host.version) 241 self.storage = SqliteStorage(database_file, host.version)
242 PersistentDict.storage = self.storage 242 PersistentDict.storage = self.storage
243 self.params = Params(host, self.storage) 243 self.params = Params(host, self.storage)
244 log.info(_("Loading default params template")) 244 log.info(_("Loading default params template"))
248 d.addCallback(lambda ignore: self.memory_data.load()) 248 d.addCallback(lambda ignore: self.memory_data.load())
249 d.addCallback(lambda ignore: self.disco.load()) 249 d.addCallback(lambda ignore: self.disco.load())
250 d.chainDeferred(self.initialized) 250 d.chainDeferred(self.initialized)
251 251
252 ## Configuration ## 252 ## Configuration ##
253
254 def parseMainConf(self):
255 """look for main .ini configuration file, and parse it"""
256 config = SafeConfigParser(defaults=C.DEFAULT_CONFIG)
257 try:
258 config.read(C.CONFIG_FILES)
259 except:
260 log.error(_("Can't read main config !"))
261 return config
262 253
263 def getConfig(self, section, name, default=None): 254 def getConfig(self, section, name, default=None):
264 """Get the main configuration option 255 """Get the main configuration option
265 256
266 @param section: section of the config file (None or '' for DEFAULT) 257 @param section: section of the config file (None or '' for DEFAULT)