Several cleanups
This commit is contained in:
@@ -30,10 +30,6 @@ def get_path(activity_name):
|
||||
"""Returns the activity path"""
|
||||
return '/' + activity_name.replace('.', '/')
|
||||
|
||||
def _get_factory(activity_name):
|
||||
"""Returns the activity factory"""
|
||||
return activity_name + '.Factory'
|
||||
|
||||
class ActivityFactory(dbus.service.Object):
|
||||
"""Dbus service that takes care of creating new instances of an activity"""
|
||||
|
||||
@@ -55,7 +51,7 @@ class ActivityFactory(dbus.service.Object):
|
||||
self._constructor = getattr(module, class_name)
|
||||
|
||||
bus = dbus.SessionBus()
|
||||
factory = _get_factory(activity_type)
|
||||
factory = activity_type
|
||||
bus_name = dbus.service.BusName(factory, bus = bus)
|
||||
dbus.service.Object.__init__(self, bus_name, get_path(factory))
|
||||
|
||||
@@ -82,7 +78,7 @@ def create(activity_name):
|
||||
"""Create a new activity from his name."""
|
||||
bus = dbus.SessionBus()
|
||||
|
||||
factory_name = _get_factory(activity_name)
|
||||
factory_name = activity_name
|
||||
factory_path = get_path(factory_name)
|
||||
|
||||
proxy_obj = bus.get_object(factory_name, factory_path)
|
||||
|
||||
@@ -3,10 +3,7 @@ from ConfigParser import ConfigParser
|
||||
|
||||
from sugar.activity.bundle import Bundle
|
||||
from sugar import env
|
||||
|
||||
class _ServiceParser(ConfigParser):
|
||||
def optionxform(self, option):
|
||||
return option
|
||||
from sugar import util
|
||||
|
||||
class _ServiceManager(object):
|
||||
def __init__(self):
|
||||
@@ -15,24 +12,10 @@ class _ServiceManager(object):
|
||||
def add(self, bundle):
|
||||
name = bundle.get_service_name()
|
||||
|
||||
service_cp = _ServiceParser()
|
||||
|
||||
section = 'D-BUS Service'
|
||||
service_cp.add_section(section)
|
||||
|
||||
# Compatibility with the old activity registry, remove after BTest-1
|
||||
# service_cp.set(section, 'Name', name)
|
||||
service_cp.set(section, 'Name', name + '.Factory')
|
||||
|
||||
# FIXME total hack
|
||||
full_exec = env.get_shell_bin_dir() + '/' + bundle.get_exec()
|
||||
full_exec += ' ' + bundle.get_path()
|
||||
service_cp.set(section, 'Exec', full_exec)
|
||||
|
||||
dest = os.path.join(self._path, name + '.service')
|
||||
fileobject = open(dest, 'w')
|
||||
service_cp.write(fileobject)
|
||||
fileobject.close()
|
||||
util.write_service(name, full_exec, self._path)
|
||||
|
||||
class BundleRegistry:
|
||||
"""Service that tracks the available activity bundles"""
|
||||
|
||||
Reference in New Issue
Block a user