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):
dialog = FirstTimeDialog()
dialog.run()
profile.update()
model = ShellModel()
shell = Shell(model)

View File

@ -31,9 +31,15 @@ from sugar import env
from sugar import setup
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 += ';' + os.path.join(sourcedir, 'shell')
bin_path += ';' + os.path.join(sourcedir, 'services/presence')
bin_path += ':' + os.path.join(sourcedir, 'shell')
bin_path += ':' + os.path.join(sourcedir, 'services/presence')
if os.environ.has_key('PATH'):
old_path = os.environ['PATH']

View File

@ -20,24 +20,36 @@ from ConfigParser import ConfigParser
from sugar import env
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():
return _nick_name
return _profile.name
def get_color():
return _color
return _profile.color
cp = ConfigParser()
config_path = os.path.join(env.get_profile_path(), 'config')
parsed = cp.read([config_path])
def update():
print 'Update'
_profile.update()
if cp.has_option('Buddy', 'NickName'):
_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
_profile = _Profile()