core: local_dir moved to config file
- ~/.sat.conf added to potential config file location - removed useless profile param from getConfig
This commit is contained in:
parent
1da78d1301
commit
7f1a741caa
7 changed files with 25 additions and 24 deletions
|
|
@ -81,8 +81,8 @@ class DBusBridgeFrontend(BridgeFrontend):
|
|||
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)
|
||||
|
|
|
|||
|
|
@ -171,10 +171,10 @@ class DbusObject(dbus.service.Object):
|
|||
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)',
|
||||
|
|
|
|||
|
|
@ -323,13 +323,11 @@ doc_param_2=%(doc_profile_key)s
|
|||
[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
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
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 @@ class SAT(service.Service):
|
|||
|
||||
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)
|
||||
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ class MailboxUser:
|
|||
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)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ try:
|
|||
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 @@ class XEP_0054():
|
|||
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)
|
||||
|
|
|
|||
|
|
@ -409,14 +409,18 @@ class Memory:
|
|||
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 @@ class Memory:
|
|||
|
||||
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 @@ class Memory:
|
|||
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue