Mercurial > libervia-backend
changeset 365:efbfccfed623
core: local_dir moved to config file
- ~/.sat.conf added to potential config file location
- removed useless profile param from getConfig
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 18 Jun 2011 17:56:59 +0200 |
parents | 312ca6f9d84a |
children | 0806a65a5fa9 |
files | frontends/src/bridge/DBus.py src/bridge/DBus.py src/bridge/bridge_constructor/bridge_template.ini src/core/sat_main.py src/plugins/plugin_misc_maildir.py src/plugins/plugin_xep_0054.py src/tools/memory.py |
diffstat | 7 files changed, 25 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/src/bridge/DBus.py Sat Jun 18 16:22:50 2011 +0200 +++ b/frontends/src/bridge/DBus.py Sat Jun 18 17:56:59 2011 +0200 @@ -81,8 +81,8 @@ def disconnect(self, profile_key="@DEFAULT@"): return self.db_comm_iface.disconnect(profile_key) - def getConfig(self, section, name, profile_key='@DEFAULT@'): - return unicode(self.db_comm_iface.getConfig(section, name, profile_key)) + def getConfig(self, section, name): + return unicode(self.db_comm_iface.getConfig(section, name)) def getContacts(self, profile_key="@DEFAULT@"): return self.db_comm_iface.getContacts(profile_key)
--- a/src/bridge/DBus.py Sat Jun 18 16:22:50 2011 +0200 +++ b/src/bridge/DBus.py Sat Jun 18 17:56:59 2011 +0200 @@ -171,10 +171,10 @@ return self.cb["disconnect"](unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, - in_signature='sss', out_signature='s', + in_signature='ss', out_signature='s', async_callbacks=None) - def getConfig(self, section, name, profile_key='@DEFAULT@'): - return self.cb["getConfig"](unicode(section), unicode(name), unicode(profile_key)) + def getConfig(self, section, name): + return self.cb["getConfig"](unicode(section), unicode(name)) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='s', out_signature='a(sa{ss}as)',
--- a/src/bridge/bridge_constructor/bridge_template.ini Sat Jun 18 16:22:50 2011 +0200 +++ b/src/bridge/bridge_constructor/bridge_template.ini Sat Jun 18 17:56:59 2011 +0200 @@ -323,13 +323,11 @@ [getConfig] type=method category=communication -sig_in=sss +sig_in=ss sig_out=s -param_2_default='@DEFAULT@' doc=get main configuration option doc_param_0=section: section of the configuration file (empty string for DEFAULT) doc_param_1=name: name of the option -doc_param_2=%(doc_profile_key)s [setParam] type=method
--- a/src/core/sat_main.py Sat Jun 18 16:22:50 2011 +0200 +++ b/src/core/sat_main.py Sat Jun 18 17:56:59 2011 +0200 @@ -22,7 +22,6 @@ CONST = { 'client_name' : u'SàT (Salut à toi)', 'client_version' : u'0.2.0D', #Please add 'D' at the end for dev versions - 'local_dir' : '~/.sat' } from twisted.application import service @@ -107,7 +106,7 @@ self.memory=Memory(self) - local_dir = os.path.expanduser(self.get_const('local_dir')) + local_dir = self.memory.getConfig('', 'local_dir') if not os.path.exists(local_dir): os.makedirs(local_dir)
--- a/src/plugins/plugin_misc_maildir.py Sat Jun 18 16:22:50 2011 +0200 +++ b/src/plugins/plugin_misc_maildir.py Sat Jun 18 17:56:59 2011 +0200 @@ -338,7 +338,7 @@ self.profile=profile self.maildir=_maildir profile_path = self.maildir._getProfilePath(profile) - full_profile_path = os.path.join(os.path.expanduser(self.maildir.host.get_const('local_dir')),profile_path) + full_profile_path = os.path.join(self.maildir.host.memory.getConfig('','local_dir'), profile_path) if not os.path.exists(full_profile_path): os.makedirs(full_profile_path,0700) mailbox_path = os.path.join(full_profile_path, MAILDIR_PATH)
--- a/src/plugins/plugin_xep_0054.py Sat Jun 18 16:22:50 2011 +0200 +++ b/src/plugins/plugin_xep_0054.py Sat Jun 18 17:56:59 2011 +0200 @@ -41,7 +41,7 @@ except ImportError: from wokkel.subprotocols import XMPPHandler -AVATAR_PATH = "/avatars" +AVATAR_PATH = "avatars" IQ_GET = '/iq[@type="get"]' NS_VCARD = 'vcard-temp' @@ -67,7 +67,7 @@ def __init__(self, host): info(_("Plugin XEP_0054 initialization")) self.host = host - self.avatar_path = os.path.expanduser(self.host.get_const('local_dir') + AVATAR_PATH) + self.avatar_path = os.path.join(self.host.memory.getConfig('', 'local_dir'), AVATAR_PATH) self.vcard_cache = host.memory.getPrivate("vcard_cache") or {} #used to store nicknames and avatar, key = jid if not os.path.exists(self.avatar_path): os.makedirs(self.avatar_path)
--- a/src/tools/memory.py Sat Jun 18 16:22:50 2011 +0200 +++ b/src/tools/memory.py Sat Jun 18 17:56:59 2011 +0200 @@ -409,14 +409,18 @@ def parseMainConf(self): """look for main .ini configuration file, and parse it""" _config = SafeConfigParser(defaults=default_config) - _config.read(['/etc/sat.conf', os.path.expanduser('~/sat.conf'), 'sat.conf']) + try: + _config.read(map(os.path.expanduser, ['/etc/sat.conf', '~/sat.conf', '~/.sat.conf', '.sat.conf'])) + except: + error (_("Can't read main config !")) + return _config - def getConfig(self, section, name, profile): + def getConfig(self, section, name): """Get the main configuration option @param section: section of the config file (None or '' for DEFAULT) @param name: name of the option - @param profile: %(doc_profile_key)s""" + """ if not section: section='DEFAULT' try: @@ -428,13 +432,13 @@ def load(self): """Load parameters and all memory things from file/db""" - param_file_xml = os.path.expanduser(self.host.get_const('local_dir')+ + param_file_xml = os.path.expanduser(self.getConfig('','local_dir')+ self.host.get_const('savefile_param_xml')) - param_file_data = os.path.expanduser(self.host.get_const('local_dir')+ + param_file_data = os.path.expanduser(self.getConfig('','local_dir')+ self.host.get_const('savefile_param_data')) - history_file = os.path.expanduser(self.host.get_const('local_dir')+ + history_file = os.path.expanduser(self.getConfig('','local_dir')+ self.host.get_const('savefile_history')) - private_file = os.path.expanduser(self.host.get_const('local_dir')+ + private_file = os.path.expanduser(self.getConfig('','local_dir')+ self.host.get_const('savefile_private')) #parameters @@ -476,13 +480,13 @@ def save(self): """Save parameters and all memory things to file/db""" #TODO: need to encrypt files (at least passwords !) and set permissions - param_file_xml = os.path.expanduser(self.host.get_const('local_dir')+ + param_file_xml = os.path.expanduser(self.getConfig('','local_dir')+ self.host.get_const('savefile_param_xml')) - param_file_data = os.path.expanduser(self.host.get_const('local_dir')+ + param_file_data = os.path.expanduser(self.getConfig('','local_dir')+ self.host.get_const('savefile_param_data')) - history_file = os.path.expanduser(self.host.get_const('local_dir')+ + history_file = os.path.expanduser(self.getConfig('','local_dir')+ self.host.get_const('savefile_history')) - private_file = os.path.expanduser(self.host.get_const('local_dir')+ + private_file = os.path.expanduser(self.getConfig('','local_dir')+ self.host.get_const('savefile_private')) self.params.save_xml(param_file_xml)