Fix some path bugs. Reload the profile when first time dialog wrote it.

This commit is contained in:
Marco Pesenti Gritti 2006-10-17 14:31:04 +02:00
parent b481373db0
commit 637a08154e
3 changed files with 37 additions and 18 deletions

View File

@ -37,6 +37,7 @@ name = profile.get_nick_name()
if not name or not len(name): if not name or not len(name):
dialog = FirstTimeDialog() dialog = FirstTimeDialog()
dialog.run() dialog.run()
profile.update()
model = ShellModel() model = ShellModel()
shell = Shell(model) shell = Shell(model)

View File

@ -31,9 +31,15 @@ from sugar import env
from sugar import setup from sugar import setup
if sourcedir: if sourcedir:
if os.environ.has_key('PYTHONPATH'):
old_path = os.environ['PYTHONPATH']
os.environ['PYTHONPATH'] = sourcedir + ':' + old_path
else:
os.environ['PYTHONPATH'] = sourcedir
bin_path = sourcedir bin_path = sourcedir
bin_path += ';' + os.path.join(sourcedir, 'shell') bin_path += ':' + os.path.join(sourcedir, 'shell')
bin_path += ';' + os.path.join(sourcedir, 'services/presence') bin_path += ':' + os.path.join(sourcedir, 'services/presence')
if os.environ.has_key('PATH'): if os.environ.has_key('PATH'):
old_path = os.environ['PATH'] old_path = os.environ['PATH']

View File

@ -20,24 +20,36 @@ from ConfigParser import ConfigParser
from sugar import env from sugar import env
from sugar.graphics.iconcolor import IconColor from sugar.graphics.iconcolor import IconColor
class _Profile(object):
def __init__(self):
self.name = None
self.color = None
self._load()
def update(self):
self._load()
def _load(self):
cp = ConfigParser()
config_path = os.path.join(env.get_profile_path(), 'config')
parsed = cp.read([config_path])
if cp.has_option('Buddy', 'NickName'):
self.name = cp.get('Buddy', 'NickName')
if cp.has_option('Buddy', 'Color'):
self.color = IconColor(cp.get('Buddy', 'Color'))
del cp
def get_nick_name(): def get_nick_name():
return _nick_name return _profile.name
def get_color(): def get_color():
return _color return _profile.color
cp = ConfigParser() def update():
config_path = os.path.join(env.get_profile_path(), 'config') print 'Update'
parsed = cp.read([config_path]) _profile.update()
if cp.has_option('Buddy', 'NickName'): _profile = _Profile()
_nick_name = cp.get('Buddy', 'NickName')
else:
_nick_name = None
if cp.has_option('Buddy', 'Color'):
_color = IconColor(cp.get('Buddy', 'Color'))
else:
_color = None
del cp