Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/activity/bundleregistry.py
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-10-31 09:48:45 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-10-31 09:48:45 (GMT)
commit92f37d31da17cb8e19295e62584ee58e88c83a77 (patch)
tree69841106ab819d354eabe2ebb37f29f47aa4af6a /sugar/activity/bundleregistry.py
parent31c07be19ed9b7096cf7a098ad541666b525c879 (diff)
Several fixes, generate the service, add a test bundle
Diffstat (limited to 'sugar/activity/bundleregistry.py')
-rw-r--r--sugar/activity/bundleregistry.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/sugar/activity/bundleregistry.py b/sugar/activity/bundleregistry.py
index 804a514..8ee1a98 100644
--- a/sugar/activity/bundleregistry.py
+++ b/sugar/activity/bundleregistry.py
@@ -1,13 +1,41 @@
import os
+from ConfigParser import ConfigParser
from sugar.activity.bundle import Bundle
+class _ServiceParser(ConfigParser):
+ def optionxform(self, option):
+ return option
+
+class _ServiceManager(object):
+ def __init__(self):
+ self._path = '/tmp/sugar-services'
+
+ if not os.path.isdir(self._path):
+ os.mkdir(self._path)
+
+ def add(self, bundle):
+ name = bundle.get_service_name()
+
+ service_cp = _ServiceParser()
+
+ section = 'D-BUS Service'
+ service_cp.add_section(section)
+ service_cp.set(section, 'Name', name)
+ service_cp.set(section, 'Exec', bundle.get_exec())
+
+ dest = os.path.join(self._path, name + '.service')
+ fileobject = open(dest, 'w')
+ service_cp.write(fileobject)
+ fileobject.close()
+
class BundleRegistry:
"""Service that tracks the available activity bundles"""
def __init__(self):
self._bundles = {}
self._search_path = []
+ self._service_manager = _ServiceManager()
def get_bundle(self, service_name):
"""Returns an bundle given his service name"""
@@ -33,8 +61,9 @@ class BundleRegistry:
self._add_bundle(bundle_dir)
def _add_bundle(self, bundle_dir):
- info_path = os.path.join(bundle_dir, 'activity.info')
+ info_path = os.path.join(bundle_dir, 'activity', 'activity.info')
if os.path.isfile(info_path):
bundle = Bundle(info_path)
if bundle.is_valid():
self._bundles[bundle.get_service_name()] = bundle
+ self._service_manager.add(bundle)