From e0bd5d1df41f1d77ae8bd66c3c2a0ab9143595cb Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 18 Dec 2006 13:47:49 +0100 Subject: [PATCH] Cleanup activity factory startup, remove duplicated argument from the Exec field --- shell/sugar-activity-factory | 14 +++----------- sugar/activity/ActivityFactory.py | 16 +++++++++++++--- sugar/env.py | 6 ++++++ 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/shell/sugar-activity-factory b/shell/sugar-activity-factory index 6065ba31..2dc8c3b5 100755 --- a/shell/sugar-activity-factory +++ b/shell/sugar-activity-factory @@ -17,30 +17,22 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import sys -import logging -import os import pygtk pygtk.require('2.0') import gobject import gtk + import dbus.glib # Work around for dbus mutex locking issue gobject.threads_init() dbus.glib.threads_init() -from sugar import logger -from sugar import env from sugar.activity import ActivityFactory -logger.start(sys.argv[1]) +sys.path.append(sys.argv[2]) -logging.info('Starting activity factory %s' % sys.argv[1]) - -if len(sys.argv) > 3: - sys.path.append(sys.argv[3]) - -ActivityFactory.register_factory(sys.argv[1], sys.argv[2]) +ActivityFactory.start_factory(sys.argv[1], sys.argv[2]) gtk.main() diff --git a/sugar/activity/ActivityFactory.py b/sugar/activity/ActivityFactory.py index ee131ef1..4acb9b63 100644 --- a/sugar/activity/ActivityFactory.py +++ b/sugar/activity/ActivityFactory.py @@ -15,6 +15,7 @@ # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. +import os import sys import logging @@ -25,6 +26,8 @@ import gtk from sugar.presence.PresenceService import PresenceService from sugar.activity import Activity +from sugar.activity.bundle import Bundle +from sugar import logger def get_path(activity_name): """Returns the activity path""" @@ -93,6 +96,13 @@ def create(activity_name): return activity -def register_factory(name, activity_class): - """Register the activity factory.""" - factory = ActivityFactory(name, activity_class) +def start_factory(activity_class, bundle_path): + """Start the activity factory.""" + bundle = Bundle(bundle_path) + + logger.start(bundle.get_name()) + + os.environ['SUGAR_BUNDLE_PATH'] = bundle_path + os.environ['SUGAR_BUNDLE_SERVICE_NAME'] = bundle.get_service_name() + + factory = ActivityFactory(bundle.get_service_name(), activity_class) diff --git a/sugar/env.py b/sugar/env.py index 391c7cdc..6b59ab52 100644 --- a/sugar/env.py +++ b/sugar/env.py @@ -24,6 +24,12 @@ try: except ImportError: from sugar.__installed__ import * +def get_bundle_path(): + if os.environ.has_key('SUGAR_BUNDLE_PATH'): + return os.environ['SUGAR_BUNDLE_PATH'] + else: + return None + def get_profile_path(): if os.environ.has_key('SUGAR_PROFILE'): profile_id = os.environ['SUGAR_PROFILE']