Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-08-26 11:35:03 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-08-26 11:35:03 (GMT)
commit93d489741d676d4ed3b3285bf732c614e6fff371 (patch)
tree26ce753585ae89108fd6e84c054dda3403a8c590
parenta7c552c038ee090018f6becad5f84f8141e3e79b (diff)
Automatically read the profile (lazily)
-rw-r--r--shell/PresenceService/PresenceService.py1
-rw-r--r--sugar/conf/ActivityRegistry.py3
-rw-r--r--sugar/conf/Profile.py36
-rw-r--r--sugar/env.py14
4 files changed, 23 insertions, 31 deletions
diff --git a/shell/PresenceService/PresenceService.py b/shell/PresenceService/PresenceService.py
index f40d6e7..f20b3dc 100644
--- a/shell/PresenceService/PresenceService.py
+++ b/shell/PresenceService/PresenceService.py
@@ -723,7 +723,6 @@ class PresenceService(object):
def main():
from sugar import TracebackUtils
- env.read_profile()
loop = gobject.MainLoop()
ps = PresenceService()
tbh = TracebackUtils.TracebackHelper()
diff --git a/sugar/conf/ActivityRegistry.py b/sugar/conf/ActivityRegistry.py
index 5ff0059..189d3d9 100644
--- a/sugar/conf/ActivityRegistry.py
+++ b/sugar/conf/ActivityRegistry.py
@@ -3,6 +3,8 @@ import os
from ConfigParser import ConfigParser
from ConfigParser import NoOptionError
+from sugar import env
+
class ActivityModule:
"""Info about an activity module. Wraps a .activity file."""
@@ -54,6 +56,7 @@ class ActivityRegistry:
def __init__(self):
self._activities = []
+ self.scan_directory(env.get_activities_dir())
def get_activity_from_id(self, activity_id):
"""Returns an activity given his identifier"""
diff --git a/sugar/conf/Profile.py b/sugar/conf/Profile.py
index c569cb3..7a6be2e 100644
--- a/sugar/conf/Profile.py
+++ b/sugar/conf/Profile.py
@@ -1,11 +1,27 @@
import os
from ConfigParser import ConfigParser
+
from sugar.canvas.IconColor import IconColor
+from sugar import env
class Profile:
def __init__(self,):
- self._path = None
+ self._path = env.get_profile_path()
self._nick_name = None
+ self._color = None
+
+ self._ensure_dirs()
+
+ cp = ConfigParser()
+ parsed = cp.read([self._get_config_path()])
+
+ if cp.has_option('Buddy', 'NickName'):
+ self._nick_name = cp.get('Buddy', 'NickName')
+ if cp.has_option('Buddy', 'Color'):
+ self._color = IconColor(cp.get('Buddy', 'Color'))
+
+ if self._color == None:
+ self.set_color(IconColor())
def _ensure_dirs(self):
try:
@@ -29,24 +45,6 @@ class Profile:
def get_path(self):
return self._path
- def set_path(self, path):
- self._path = path
-
- def read(self):
- self._color = None
- self._ensure_dirs()
-
- cp = ConfigParser()
- parsed = cp.read([self._get_config_path()])
-
- if cp.has_option('Buddy', 'NickName'):
- self._nick_name = cp.get('Buddy', 'NickName')
- if cp.has_option('Buddy', 'Color'):
- self._color = IconColor(cp.get('Buddy', 'Color'))
-
- if self._color == None:
- self.set_color(IconColor())
-
def save(self):
cp = ConfigParser()
diff --git a/sugar/env.py b/sugar/env.py
index 992bcf3..c11c83a 100644
--- a/sugar/env.py
+++ b/sugar/env.py
@@ -8,7 +8,6 @@ except ImportError:
from sugar.__installed__ import *
import sugar.setup
-import sugar.conf
def add_to_python_path(path):
sys.path.insert(0, path)
@@ -41,16 +40,6 @@ def setup():
sugar.setup.write_service('org.laptop.Presence', bin,
sugar_activities_dir)
- registry = sugar.conf.get_activity_registry()
- registry.scan_directory(sugar_activities_dir)
-
- read_profile()
-
-def read_profile():
- profile = sugar.conf.get_profile()
- profile.set_path(get_profile_path())
- profile.read()
-
def get_profile_path():
if os.environ.has_key('SUGAR_PROFILE'):
profile_id = os.environ['SUGAR_PROFILE']
@@ -63,5 +52,8 @@ def get_profile_path():
def get_data_dir():
return sugar_data_dir
+def get_activities_dir():
+ return sugar_activities_dir
+
def get_dbus_config():
return sugar_dbus_config