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:
Goffi 2011-06-18 17:56:59 +02:00
commit 7f1a741caa

View file

@ -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)