Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
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
parent31c07be19ed9b7096cf7a098ad541666b525c879 (diff)
Several fixes, generate the service, add a test bundle
Diffstat (limited to 'sugar')
-rw-r--r--sugar/activity/bundle.py28
-rw-r--r--sugar/activity/bundleregistry.py31
2 files changed, 50 insertions, 9 deletions
diff --git a/sugar/activity/bundle.py b/sugar/activity/bundle.py
index 07ff544..286c979 100644
--- a/sugar/activity/bundle.py
+++ b/sugar/activity/bundle.py
@@ -13,24 +13,32 @@ class Bundle:
cp = ConfigParser()
cp.read([info_path])
- if cp.has_option('Activity', 'service_name'):
- self._service_name = cp.get('Activity', 'service_name')
+ section = 'Activity'
+
+ if cp.has_option(section, 'service_name'):
+ self._service_name = cp.get(section, 'service_name')
else:
self._valid = False
logging.error('%s must specify a service name' % info_path)
- if cp.has_option('Activity', 'name'):
- self._service_name = cp.get('Activity', 'name')
+ if cp.has_option(section, 'name'):
+ self._name = cp.get(section, 'name')
else:
self._valid = False
logging.error('%s must specify a name' % info_path)
- if cp.has_option('Activity', 'show_launcher'):
- if cp.get('Activity', 'show_launcher') == 'yes':
+ if cp.has_option(section, 'exec'):
+ self._exec = cp.get(section, 'exec')
+ else:
+ self._valid = False
+ logging.error('%s must specify an exec' % info_path)
+
+ if cp.has_option(section, 'show_launcher'):
+ if cp.get(section, 'show_launcher') == 'yes':
self._show_launcher = True
- if cp.has_option('Activity', 'icon'):
- self._icon = cp.get('Activity', 'icon')
+ if cp.has_option(section, 'icon'):
+ self._icon = cp.get(section, 'icon')
def is_valid(self):
return self._valid
@@ -47,6 +55,10 @@ class Bundle:
"""Get the activity icon name"""
return self._icon
+ def get_exec(self):
+ """Get the command to execute to launch the activity factory"""
+ return self._exec
+
def get_show_launcher(self):
"""Get whether there should be a visible launcher for the activity"""
return self._show_launcher
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)