Cleanup activity factory startup, remove duplicated argument from the Exec field

This commit is contained in:
Marco Pesenti Gritti 2006-12-18 13:47:49 +01:00
parent 09b096d4d0
commit e0bd5d1df4
3 changed files with 22 additions and 14 deletions

View File

@ -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()

View File

@ -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)

View File

@ -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']