diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-07-12 15:21:22 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2006-07-12 15:21:22 (GMT) |
commit | d12b780074b05b0abcaf6b3877a9a4047c6e0d0e (patch) | |
tree | 13e33f093001aa2e5b639c8dfddcc2a64ed7797d /shell/ActivityRegistry.py | |
parent | be806eb1918f7db90e661b5fcb4e260a0b1ba669 (diff) |
More work on session refactoring
Diffstat (limited to 'shell/ActivityRegistry.py')
-rw-r--r-- | shell/ActivityRegistry.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/shell/ActivityRegistry.py b/shell/ActivityRegistry.py index 9f1e857..2ddf767 100644 --- a/shell/ActivityRegistry.py +++ b/shell/ActivityRegistry.py @@ -1,4 +1,9 @@ import logging +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.""" @@ -17,9 +22,9 @@ class ActivityModule: """Get the activity identifier""" return self._id - def get_class(self): + def get_exec(self): """Get the activity executable""" - return self._class + return self._exec def get_directory(self): """Get the path to activity directory.""" @@ -33,9 +38,9 @@ class ActivityRegistry: def scan_directory(self, path): """Scan a directory for activities and add them to the registry.""" - if os.path.isdir(base_dir): - for filename in os.listdir(base_dir): - activity_dir = os.path.join(base_dir, filename) + if os.path.isdir(path): + for filename in os.listdir(path): + activity_dir = os.path.join(path, filename) if os.path.isdir(activity_dir): for filename in os.listdir(activity_dir): if filename.endswith(".activity"): @@ -50,18 +55,26 @@ class ActivityRegistry: try: activity_id = cp.get('Activity', 'id') + except NoOptionError: + logging.error('%s miss the required id option' % (path)) + return False + + try: name = cp.get('Activity', 'name') except NoOptionError: - logging.error('%s miss a required option' % (path)) + logging.error('%s miss the required name option' % (path)) + return False if cp.has_option('Activity', 'exec'): activity_exec = cp.get('Activity', 'exec') elif cp.has_option('Activity', 'python_module'): python_module = cp.get('Activity', 'python_module') activity_exec = 'python -m sugar/activity/Activity %s %s' \ - % (name, python_module) + % (activity_id, python_module) + env.add_to_python_path(directory) else: logging.error('%s must specifiy exec or python_module' % (path)) + return False module = ActivityModule(name, activity_id, activity_exec, directory) self._activities.append(module) |