From ecf50d8c565079db2c2903363d8dade2bb418519 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Fri, 20 May 2005 18:08:24 +0000 Subject: [PATCH] win32: store the config in the correct place, and move it if existes in the old place --- src/common/optparser.py | 2 +- src/gajim.py | 33 ++++++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/common/optparser.py b/src/common/optparser.py index de53d2779..a0f430591 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -22,7 +22,7 @@ from common import gajim class OptionsParser: def __init__(self, filename): - self.__filename = os.path.expanduser(filename) + self.__filename = filename def read_line(self, line): index = line.find(' = ') diff --git a/src/gajim.py b/src/gajim.py index f4866c1cb..47bab4013 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -48,23 +48,38 @@ from common import optparser profile = '' try: - opts, args = getopt.getopt(sys.argv[1:], "hp:", [ "help", "profile=" ]) + opts, args = getopt.getopt(sys.argv[1:], 'hp:', [ 'help', 'profile=' ]) except getopt.error, msg: print msg - print "for help use --help" + print 'for help use --help' sys.exit(2) for o, a in opts: - if o in ("-h", "--help"): - print "gajim [--help] [--profile name]" + if o in ('-h', '--help'): + print 'gajim [--help] [--profile name]' sys.exit(0) - elif o in ("-p", "--profile"): # gajim --profile name + elif o in ('-p', '--profile'): # gajim --profile name profile = a -config_name = "~/.gajim/config" -if profile: - config_name += ".%s" % profile -parser = optparser.OptionsParser(config_name) +config_filename = os.path.expanduser('~/.gajim/config') +if os.name == 'nt': + do_move = False + if os.path.isfile(config_filename): + do_move = True + old_path = config_filename + try: + # Documents and Settings\[User Name]\Application Data\Gajim\logs + config_filename = os.environ['appdata'] + '/Gajim/config' + except KeyError: + # win9x, so use ~/Gajim/logs which is WINDOWS\Application Data\Gajim\logs + config_filename = os.path.expanduser('~/Gajim/config') + if do_move: + os.renames(old_path, config_filename) + +if profile: + config_filename += '.%s' % profile + +parser = optparser.OptionsParser(config_filename) try: import winsound # windows-only built-in module for playing wav