win32: store the config in the correct place, and move it if existes in the old place
This commit is contained in:
parent
686a9a0bd9
commit
ecf50d8c56
|
@ -22,7 +22,7 @@ from common import gajim
|
||||||
|
|
||||||
class OptionsParser:
|
class OptionsParser:
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
self.__filename = os.path.expanduser(filename)
|
self.__filename = filename
|
||||||
|
|
||||||
def read_line(self, line):
|
def read_line(self, line):
|
||||||
index = line.find(' = ')
|
index = line.find(' = ')
|
||||||
|
|
33
src/gajim.py
33
src/gajim.py
|
@ -48,23 +48,38 @@ from common import optparser
|
||||||
|
|
||||||
profile = ''
|
profile = ''
|
||||||
try:
|
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:
|
except getopt.error, msg:
|
||||||
print msg
|
print msg
|
||||||
print "for help use --help"
|
print 'for help use --help'
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
for o, a in opts:
|
for o, a in opts:
|
||||||
if o in ("-h", "--help"):
|
if o in ('-h', '--help'):
|
||||||
print "gajim [--help] [--profile name]"
|
print 'gajim [--help] [--profile name]'
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif o in ("-p", "--profile"): # gajim --profile name
|
elif o in ('-p', '--profile'): # gajim --profile name
|
||||||
profile = a
|
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:
|
try:
|
||||||
import winsound # windows-only built-in module for playing wav
|
import winsound # windows-only built-in module for playing wav
|
||||||
|
|
Loading…
Reference in New Issue