Use versioned configuration directory

This commit is contained in:
Cédric Krier committed 2009-11-28 00:27:26 +01:00
1 parent ceef62f2eb
commit d33cedd569
5 files changed
+21 -34

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Use versioned configuration directory
* Next and Previous scroll per page on list and don't loop
* Add AccelGroup on search windows (CTRL+Return)
* Use same keyboard shortcut for xxx2many than for other fields
+2 -2
View File
@@ -919,8 +919,8 @@ Configuration File
::
~./tryton # General configuration
~./trytonsc # Shortcut configuration
~/.config/tryton/x.y/tryton.conf # General configuration
~/.config/tryton/x.y/accel.map # Accelerators configuration
:Authors:
Udo Spallek, Bertrand Chenal, Mattias Behrle, Anne Krings
+2 -2
View File
@@ -15,7 +15,7 @@ import logging
from tryton import version
from tryton import config
from tryton.config import CONFIG, CURRENT_DIR, PREFIX, PIXMAPS_DIR, \
TRYTON_ICON, get_home_dir
TRYTON_ICON, get_config_dir
from tryton import translate
from tryton import gui
import traceback
@@ -105,7 +105,7 @@ class TrytonClient(object):
except KeyboardInterrupt:
CONFIG.save()
if hasattr(gtk, 'accel_map_save'):
gtk.accel_map_save(os.path.join(get_home_dir(), '.trytonsc'))
gtk.accel_map_save(os.path.join(get_config_dir(), 'accel.map'))
if __name__ == "__main__":
CLIENT = TrytonClient()
+12 -27
View File
@@ -14,33 +14,18 @@ import gtk
_ = gettext.gettext
def get_home_dir():
"""
Return the closest possible equivalent to a 'home' directory.
For Posix systems, this is $HOME, and on NT it's $HOMEDRIVE\$HOMEPATH.
Currently only Posix and NT are implemented, a HomeDirError exception is
raised for all other OSes.
"""
if os.name == 'nt':
return os.path.join(os.environ['HOMEDRIVE'], os.environ['HOMEPATH'])
return os.environ['HOME']
if os.name == 'posix':
return os.path.expanduser('~')
elif os.name == 'nt':
try:
return os.path.join(os.environ['HOMEDRIVE'], os.environ['HOMEPATH'])
except:
try:
import _winreg as wreg
key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
"Software\Microsoft\Windows\Current" \
"Version\Explorer\Shell Folders")
homedir = wreg.QueryValueEx(key, 'Personal')[0]
key.Close()
return homedir
except:
return 'C:\\'
elif os.name == 'dos':
return 'C:\\'
else:
return '.'
def get_config_dir():
if os.name == 'nt':
return os.path.join(os.environ['APPDATA'], '.config', 'tryton',
VERSION.rsplit('.', 1)[0])
return os.path.join(os.environ['HOME'], '.config', 'tryton',
VERSION.rsplit('.', 1)[0])
if not os.path.isdir(get_config_dir()):
os.makedirs(get_config_dir(), 0700)
def find_path(progs, args):
if os.name == 'nt':
@@ -126,7 +111,7 @@ class ConfigManager(object):
if opt.config and not os.path.isfile(opt.config):
raise Exception(_('File "%s" not found') % (opt.config,))
self.rcfile = opt.config or os.path.join(get_home_dir(), '.tryton')
self.rcfile = opt.config or os.path.join(get_config_dir(), 'tryton.conf')
self.load()
for arg in ('log_level', 'log_logger'):
+4 -3
View File
@@ -7,7 +7,8 @@ import urlparse
import gobject
import gtk
import tryton.rpc as rpc
from tryton.config import CONFIG, TRYTON_ICON, PIXMAPS_DIR, DATA_DIR, get_home_dir
from tryton.config import CONFIG, TRYTON_ICON, PIXMAPS_DIR, DATA_DIR, \
get_config_dir
import tryton.common as common
from tryton.action import Action
from tryton.gui.window import Window
@@ -97,7 +98,7 @@ class Main(object):
gtk.gdk.CONTROL_MASK)
if hasattr(gtk, 'accel_map_load'):
gtk.accel_map_load(os.path.join(get_home_dir(), '.trytonsc'))
gtk.accel_map_load(os.path.join(get_config_dir(), 'accel.map'))
self.tooltips = common.Tooltips()
@@ -1270,7 +1271,7 @@ class Main(object):
CONFIG['client.default_height'] = Main.get_main()._height
CONFIG.save()
if hasattr(gtk, 'accel_map_save'):
gtk.accel_map_save(os.path.join(get_home_dir(), '.trytonsc'))
gtk.accel_map_save(os.path.join(get_config_dir(), 'accel.map'))
gtk.main_quit()
sys.exit()