Add a class attribute as per the updated spec.

Cleanups.
master
Marco Pesenti Gritti 18 years ago
parent 3742219d6c
commit 02f375b710

@ -17,6 +17,7 @@
import os
import sys
from optparse import OptionParser
import gobject
import gtk
@ -77,15 +78,20 @@ class ActivityFactoryService(dbus.service.Object):
def run(args):
"""Start the activity factory."""
sys.path.insert(0, args[2])
parser = OptionParser()
parser.add_option("-p", "--bundle-path", dest="bundle_path",
help="path to the activity bundle")
(options, args) = parser.parse_args()
bundle = Bundle(args[2])
sys.path.insert(0, options.bundle_path)
bundle = Bundle(options.bundle_path)
logger.start(bundle.get_name())
os.environ['SUGAR_BUNDLE_PATH'] = args[2]
os.environ['SUGAR_BUNDLE_PATH'] = options.bundle_path
os.environ['SUGAR_BUNDLE_SERVICE_NAME'] = bundle.get_service_name()
os.environ['SUGAR_BUNDLE_DEFAULT_TYPE'] = bundle.get_default_type()
factory = ActivityFactoryService(bundle.get_service_name(), args[1])
factory = ActivityFactoryService(bundle.get_service_name(), args[0])
gtk.main()

@ -1,8 +1,11 @@
import logging
import os
from ConfigParser import ConfigParser
from sugar import env
_PYTHON_FACTORY='sugar-activity-factory'
class Bundle:
"""Info about an activity bundle. Wraps the activity.info file."""
def __init__(self, path):
@ -38,11 +41,18 @@ class Bundle:
self._valid = False
logging.error('%s must specify a name' % self._path)
if cp.has_option(section, 'exec'):
if cp.has_option(section, 'class'):
self._class = cp.get(section, 'class')
self._exec = '%s %s --bundle-path=%s' % (
os.path.join(env.get_shell_bin_dir(), _PYTHON_FACTORY),
self._class, self.get_path())
elif cp.has_option(section, 'exec'):
self._class = None
self._exec = cp.get(section, 'exec')
else:
self._exec = None
self._valid = False
logging.error('%s must specify an exec' % self._path)
logging.error('%s must specify exec or class' % self._path)
if cp.has_option(section, 'show_launcher'):
if cp.get(section, 'show_launcher') == 'no':
@ -94,6 +104,10 @@ class Bundle:
"""Get the command to execute to launch the activity factory"""
return self._exec
def get_class(self):
"""Get the main Activity class"""
return self._exec
def get_show_launcher(self):
"""Get whether there should be a visible launcher for the activity"""
return self._show_launcher

@ -11,13 +11,8 @@ class _ServiceManager(object):
self._path = env.get_user_service_dir()
def add(self, bundle):
name = bundle.get_service_name()
# FIXME evil hack. Probably need to fix Exec spec
full_exec = env.get_shell_bin_dir() + '/' + bundle.get_exec()
full_exec += ' ' + bundle.get_path()
util.write_service(name, full_exec, self._path)
util.write_service(bundle.get_service_name(),
bundle.get_exec(), self._path)
class BundleRegistry(gobject.GObject):
"""Service that tracks the available activity bundles"""

Loading…
Cancel
Save