From 637a08154ed1ebe6c6dd5ee326288fba061842f6 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 17 Oct 2006 14:31:04 +0200 Subject: [PATCH] Fix some path bugs. Reload the profile when first time dialog wrote it. --- shell/sugar-shell | 1 + sugar-emulator | 10 ++++++++-- sugar/profile.py | 44 ++++++++++++++++++++++++++++---------------- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/shell/sugar-shell b/shell/sugar-shell index 93534927..32fc0351 100755 --- a/shell/sugar-shell +++ b/shell/sugar-shell @@ -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) diff --git a/sugar-emulator b/sugar-emulator index dafc2751..9b629d4b 100755 --- a/sugar-emulator +++ b/sugar-emulator @@ -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'] diff --git a/sugar/profile.py b/sugar/profile.py index 12eb08be..2ba1fd7b 100644 --- a/sugar/profile.py +++ b/sugar/profile.py @@ -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()