Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/activity
diff options
context:
space:
mode:
Diffstat (limited to 'sugar/activity')
-rw-r--r--sugar/activity/Activity.py248
-rw-r--r--sugar/activity/ActivityFactory.py96
-rw-r--r--sugar/activity/__init__.py10
-rw-r--r--sugar/activity/bundle.py160
-rw-r--r--sugar/activity/bundlebuilder.py176
-rw-r--r--sugar/activity/bundleregistry.py86
6 files changed, 388 insertions, 388 deletions
diff --git a/sugar/activity/Activity.py b/sugar/activity/Activity.py
index 2f27303..215ee85 100644
--- a/sugar/activity/Activity.py
+++ b/sugar/activity/Activity.py
@@ -32,133 +32,133 @@ ACTIVITY_SERVICE_PATH = "/org/laptop/Activity"
ACTIVITY_INTERFACE = "org.laptop.Activity"
def get_service_name(xid):
- return ACTIVITY_SERVICE_NAME + '%d' % xid
+ return ACTIVITY_SERVICE_NAME + '%d' % xid
def get_object_path(xid):
- return ACTIVITY_SERVICE_PATH + "/%s" % xid
+ return ACTIVITY_SERVICE_PATH + "/%s" % xid
class ActivityDbusService(dbus.service.Object):
- """Base dbus service object that each Activity uses to export dbus methods.
-
- The dbus service is separate from the actual Activity object so that we can
- tightly control what stuff passes through the dbus python bindings."""
-
- def start(self, pservice, activity):
- self._activity = activity
- self._pservice = pservice
-
- @dbus.service.method(ACTIVITY_INTERFACE)
- def share(self):
- """Called by the shell to request the activity to share itself on the network."""
- self._activity.share()
-
- @dbus.service.method(ACTIVITY_INTERFACE)
- def join(self, activity_ps_path):
- """Join the activity specified by its presence service path"""
- activity_ps = self._pservice.get(activity_ps_path)
- return self._activity.join(activity_ps)
-
- @dbus.service.method(ACTIVITY_INTERFACE)
- def get_id(self):
- """Get the activity identifier"""
- return self._activity.get_id()
-
- @dbus.service.method(ACTIVITY_INTERFACE)
- def get_type(self):
- """Get the activity type"""
- return self._activity.get_type()
-
- @dbus.service.method(ACTIVITY_INTERFACE)
- def get_shared(self):
- """Returns True if the activity is shared on the mesh."""
- return self._activity.get_shared()
-
- @dbus.service.method(ACTIVITY_INTERFACE,
- in_signature="sas", out_signature="")
- def execute(self, command, args):
- self._activity.execute(command, args)
+ """Base dbus service object that each Activity uses to export dbus methods.
+
+ The dbus service is separate from the actual Activity object so that we can
+ tightly control what stuff passes through the dbus python bindings."""
+
+ def start(self, pservice, activity):
+ self._activity = activity
+ self._pservice = pservice
+
+ @dbus.service.method(ACTIVITY_INTERFACE)
+ def share(self):
+ """Called by the shell to request the activity to share itself on the network."""
+ self._activity.share()
+
+ @dbus.service.method(ACTIVITY_INTERFACE)
+ def join(self, activity_ps_path):
+ """Join the activity specified by its presence service path"""
+ activity_ps = self._pservice.get(activity_ps_path)
+ return self._activity.join(activity_ps)
+
+ @dbus.service.method(ACTIVITY_INTERFACE)
+ def get_id(self):
+ """Get the activity identifier"""
+ return self._activity.get_id()
+
+ @dbus.service.method(ACTIVITY_INTERFACE)
+ def get_type(self):
+ """Get the activity type"""
+ return self._activity.get_type()
+
+ @dbus.service.method(ACTIVITY_INTERFACE)
+ def get_shared(self):
+ """Returns True if the activity is shared on the mesh."""
+ return self._activity.get_shared()
+
+ @dbus.service.method(ACTIVITY_INTERFACE,
+ in_signature="sas", out_signature="")
+ def execute(self, command, args):
+ self._activity.execute(command, args)
class Activity(gtk.Window):
- """Base Activity class that all other Activities derive from."""
-
- def __init__(self):
- gtk.Window.__init__(self)
-
- self.connect('destroy', self.__destroy_cb)
-
- self._shared = False
- self._activity_id = None
- self._default_type = None
- self._service = None
- self._pservice = PresenceService()
-
- self.present()
-
- group = gtk.Window()
- group.realize()
- self.window.set_group(group.window)
-
- bus = dbus.SessionBus()
- xid = self.window.xid
-
- bus_name = dbus.service.BusName(get_service_name(xid), bus=bus)
- self._bus = ActivityDbusService(bus_name, get_object_path(xid))
- self._bus.start(self._pservice, self)
-
- def set_type(self, activity_type):
- """Sets the activity type."""
- self._activity_type = activity_type
- self._default_type = activity.get_default_type(activity_type)
-
- def get_type(self):
- """Gets the activity type."""
- return self._activity_type
-
- def get_default_type(self):
- return self._default_type
-
- def get_shared(self):
- """Returns TRUE if the activity is shared on the mesh."""
- return self._shared
-
- def get_id(self):
- """Get the unique activity identifier."""
- if self._activity_id == None:
- self._activity_id = sugar.util.unique_id()
- return self._activity_id
-
- def join(self, activity_ps):
- """Join an activity shared on the network."""
- self._shared = True
- self._activity_id = activity_ps.get_id()
-
- # Publish the default service, it's a copy of
- # one of those we found on the network.
- services = activity_ps.get_services_of_type(self._default_type)
- if len(services) > 0:
- service = services[0]
- addr = service.get_address()
- port = service.get_port()
- properties = service.get_published_values()
- self._service = self._pservice.share_activity(
- self, self._default_type, properties, addr, port)
- else:
- logging.error('Cannot join the activity')
-
- def share(self):
- """Share the activity on the network."""
- logging.debug('Share activity %s on the network.' % self.get_id())
-
- self._service = self._pservice.share_activity(self, self._default_type)
- self._shared = True
-
- def execute(self, command, args):
- """Execute the given command with args"""
- pass
-
- def __destroy_cb(self, window):
- if self._bus:
- del self._bus
- self._bus = None
- if self._service:
- self._pservice.unregister_service(self._service)
+ """Base Activity class that all other Activities derive from."""
+
+ def __init__(self):
+ gtk.Window.__init__(self)
+
+ self.connect('destroy', self.__destroy_cb)
+
+ self._shared = False
+ self._activity_id = None
+ self._default_type = None
+ self._service = None
+ self._pservice = PresenceService()
+
+ self.present()
+
+ group = gtk.Window()
+ group.realize()
+ self.window.set_group(group.window)
+
+ bus = dbus.SessionBus()
+ xid = self.window.xid
+
+ bus_name = dbus.service.BusName(get_service_name(xid), bus=bus)
+ self._bus = ActivityDbusService(bus_name, get_object_path(xid))
+ self._bus.start(self._pservice, self)
+
+ def set_type(self, activity_type):
+ """Sets the activity type."""
+ self._activity_type = activity_type
+ self._default_type = activity.get_default_type(activity_type)
+
+ def get_type(self):
+ """Gets the activity type."""
+ return self._activity_type
+
+ def get_default_type(self):
+ return self._default_type
+
+ def get_shared(self):
+ """Returns TRUE if the activity is shared on the mesh."""
+ return self._shared
+
+ def get_id(self):
+ """Get the unique activity identifier."""
+ if self._activity_id == None:
+ self._activity_id = sugar.util.unique_id()
+ return self._activity_id
+
+ def join(self, activity_ps):
+ """Join an activity shared on the network."""
+ self._shared = True
+ self._activity_id = activity_ps.get_id()
+
+ # Publish the default service, it's a copy of
+ # one of those we found on the network.
+ services = activity_ps.get_services_of_type(self._default_type)
+ if len(services) > 0:
+ service = services[0]
+ addr = service.get_address()
+ port = service.get_port()
+ properties = service.get_published_values()
+ self._service = self._pservice.share_activity(
+ self, self._default_type, properties, addr, port)
+ else:
+ logging.error('Cannot join the activity')
+
+ def share(self):
+ """Share the activity on the network."""
+ logging.debug('Share activity %s on the network.' % self.get_id())
+
+ self._service = self._pservice.share_activity(self, self._default_type)
+ self._shared = True
+
+ def execute(self, command, args):
+ """Execute the given command with args"""
+ pass
+
+ def __destroy_cb(self, window):
+ if self._bus:
+ del self._bus
+ self._bus = None
+ if self._service:
+ self._pservice.unregister_service(self._service)
diff --git a/sugar/activity/ActivityFactory.py b/sugar/activity/ActivityFactory.py
index 66eba74..ee131ef 100644
--- a/sugar/activity/ActivityFactory.py
+++ b/sugar/activity/ActivityFactory.py
@@ -27,72 +27,72 @@ from sugar.presence.PresenceService import PresenceService
from sugar.activity import Activity
def get_path(activity_name):
- """Returns the activity path"""
- return '/' + activity_name.replace('.', '/')
+ """Returns the activity path"""
+ return '/' + activity_name.replace('.', '/')
class ActivityFactory(dbus.service.Object):
- """Dbus service that takes care of creating new instances of an activity"""
+ """Dbus service that takes care of creating new instances of an activity"""
- def __init__(self, activity_type, activity_class):
- self._activity_type = activity_type
- self._activities = []
+ def __init__(self, activity_type, activity_class):
+ self._activity_type = activity_type
+ self._activities = []
- splitted_module = activity_class.rsplit('.', 1)
- module_name = splitted_module[0]
- class_name = splitted_module[1]
+ splitted_module = activity_class.rsplit('.', 1)
+ module_name = splitted_module[0]
+ class_name = splitted_module[1]
- module = __import__(module_name)
- for comp in module_name.split('.')[1:]:
- module = getattr(module, comp)
- if hasattr(module, 'start'):
- module.start()
+ module = __import__(module_name)
+ for comp in module_name.split('.')[1:]:
+ module = getattr(module, comp)
+ if hasattr(module, 'start'):
+ module.start()
- self._module = module
- self._constructor = getattr(module, class_name)
-
- bus = dbus.SessionBus()
- factory = activity_type
- bus_name = dbus.service.BusName(factory, bus = bus)
- dbus.service.Object.__init__(self, bus_name, get_path(factory))
+ self._module = module
+ self._constructor = getattr(module, class_name)
+
+ bus = dbus.SessionBus()
+ factory = activity_type
+ bus_name = dbus.service.BusName(factory, bus = bus)
+ dbus.service.Object.__init__(self, bus_name, get_path(factory))
- @dbus.service.method("com.redhat.Sugar.ActivityFactory")
- def create(self):
- activity = self._constructor()
- activity.set_type(self._activity_type)
+ @dbus.service.method("com.redhat.Sugar.ActivityFactory")
+ def create(self):
+ activity = self._constructor()
+ activity.set_type(self._activity_type)
- self._activities.append(activity)
- activity.connect('destroy', self._activity_destroy_cb)
+ self._activities.append(activity)
+ activity.connect('destroy', self._activity_destroy_cb)
- return activity.window.xid
+ return activity.window.xid
- def _activity_destroy_cb(self, activity):
- self._activities.remove(activity)
+ def _activity_destroy_cb(self, activity):
+ self._activities.remove(activity)
- if hasattr(self._module, 'stop'):
- self._module.stop()
+ if hasattr(self._module, 'stop'):
+ self._module.stop()
- if len(self._activities) == 0:
- gtk.main_quit()
+ if len(self._activities) == 0:
+ gtk.main_quit()
def create(activity_name):
- """Create a new activity from his name."""
- bus = dbus.SessionBus()
+ """Create a new activity from his name."""
+ bus = dbus.SessionBus()
- factory_name = activity_name
- factory_path = get_path(factory_name)
+ factory_name = activity_name
+ factory_path = get_path(factory_name)
- proxy_obj = bus.get_object(factory_name, factory_path)
- factory = dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityFactory")
+ proxy_obj = bus.get_object(factory_name, factory_path)
+ factory = dbus.Interface(proxy_obj, "com.redhat.Sugar.ActivityFactory")
- xid = factory.create()
+ xid = factory.create()
- bus = dbus.SessionBus()
- proxy_obj = bus.get_object(Activity.get_service_name(xid),
- Activity.get_object_path(xid))
- activity = dbus.Interface(proxy_obj, Activity.ACTIVITY_INTERFACE)
+ bus = dbus.SessionBus()
+ proxy_obj = bus.get_object(Activity.get_service_name(xid),
+ Activity.get_object_path(xid))
+ activity = dbus.Interface(proxy_obj, Activity.ACTIVITY_INTERFACE)
- return activity
+ return activity
def register_factory(name, activity_class):
- """Register the activity factory."""
- factory = ActivityFactory(name, activity_class)
+ """Register the activity factory."""
+ factory = ActivityFactory(name, activity_class)
diff --git a/sugar/activity/__init__.py b/sugar/activity/__init__.py
index 959c0a1..1e606d5 100644
--- a/sugar/activity/__init__.py
+++ b/sugar/activity/__init__.py
@@ -9,10 +9,10 @@ sizes = 'gtk-large-toolbar=%d, %d' % (grid.dimension(1), grid.dimension(1))
settings.set_string_property('gtk-icon-sizes', sizes, '')
def get_default_type(activity_type):
- """Get the activity default type.
+ """Get the activity default type.
- It's the type of the main network service which tracks presence
+ It's the type of the main network service which tracks presence
and provides info about the activity, for example the title."""
- splitted_id = activity_type.split('.')
- splitted_id.reverse()
- return '_' + '_'.join(splitted_id) + '._udp'
+ splitted_id = activity_type.split('.')
+ splitted_id.reverse()
+ return '_' + '_'.join(splitted_id) + '._udp'
diff --git a/sugar/activity/bundle.py b/sugar/activity/bundle.py
index f9263a3..00d2d52 100644
--- a/sugar/activity/bundle.py
+++ b/sugar/activity/bundle.py
@@ -4,83 +4,83 @@ import os
from ConfigParser import ConfigParser
class Bundle:
- """Info about an activity bundle. Wraps the activity.info file."""
- def __init__(self, path):
- self._name = None
- self._icon = None
- self._service_name = None
- self._show_launcher = True
- self._valid = True
- self._path = path
- self._activity_version = 0
-
- info_path = os.path.join(path, 'activity', 'activity.info')
- if os.path.isfile(info_path):
- self._parse_info(info_path)
- else:
- self._valid = False
-
- def _parse_info(self, info_path):
- cp = ConfigParser()
- cp.read([info_path])
-
- 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' % self._path)
-
- if cp.has_option(section, 'name'):
- self._name = cp.get(section, 'name')
- else:
- self._valid = False
- logging.error('%s must specify a name' % self._path)
-
- if cp.has_option(section, 'exec'):
- self._exec = cp.get(section, 'exec')
- else:
- self._valid = False
- logging.error('%s must specify an exec' % self._path)
-
- if cp.has_option(section, 'show_launcher'):
- if cp.get(section, 'show_launcher') == 'no':
- self._show_launcher = False
-
- if cp.has_option(section, 'icon'):
- self._icon = cp.get(section, 'icon')
-
- if cp.has_option(section, 'activity_version'):
- self._activity_version = int(cp.get(section, 'activity_version'))
-
- def is_valid(self):
- return self._valid
-
- def get_path(self):
- """Get the activity bundle path."""
- return self._path
-
- def get_name(self):
- """Get the activity user visible name."""
- return self._name
-
- def get_service_name(self):
- """Get the activity service name"""
- return self._service_name
-
- def get_icon(self):
- """Get the activity icon name"""
- return self._icon
-
- def get_activity_version(self):
- """Get the activity version"""
- return self._activity_version
-
- 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
+ """Info about an activity bundle. Wraps the activity.info file."""
+ def __init__(self, path):
+ self._name = None
+ self._icon = None
+ self._service_name = None
+ self._show_launcher = True
+ self._valid = True
+ self._path = path
+ self._activity_version = 0
+
+ info_path = os.path.join(path, 'activity', 'activity.info')
+ if os.path.isfile(info_path):
+ self._parse_info(info_path)
+ else:
+ self._valid = False
+
+ def _parse_info(self, info_path):
+ cp = ConfigParser()
+ cp.read([info_path])
+
+ 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' % self._path)
+
+ if cp.has_option(section, 'name'):
+ self._name = cp.get(section, 'name')
+ else:
+ self._valid = False
+ logging.error('%s must specify a name' % self._path)
+
+ if cp.has_option(section, 'exec'):
+ self._exec = cp.get(section, 'exec')
+ else:
+ self._valid = False
+ logging.error('%s must specify an exec' % self._path)
+
+ if cp.has_option(section, 'show_launcher'):
+ if cp.get(section, 'show_launcher') == 'no':
+ self._show_launcher = False
+
+ if cp.has_option(section, 'icon'):
+ self._icon = cp.get(section, 'icon')
+
+ if cp.has_option(section, 'activity_version'):
+ self._activity_version = int(cp.get(section, 'activity_version'))
+
+ def is_valid(self):
+ return self._valid
+
+ def get_path(self):
+ """Get the activity bundle path."""
+ return self._path
+
+ def get_name(self):
+ """Get the activity user visible name."""
+ return self._name
+
+ def get_service_name(self):
+ """Get the activity service name"""
+ return self._service_name
+
+ def get_icon(self):
+ """Get the activity icon name"""
+ return self._icon
+
+ def get_activity_version(self):
+ """Get the activity version"""
+ return self._activity_version
+
+ 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/bundlebuilder.py b/sugar/activity/bundlebuilder.py
index c313523..4ab4f7d 100644
--- a/sugar/activity/bundlebuilder.py
+++ b/sugar/activity/bundlebuilder.py
@@ -25,71 +25,71 @@ import shutil
from sugar.activity.bundle import Bundle
class _SvnFileList(list):
- def __init__(self):
- f = os.popen('svn list -R')
- for line in f.readlines():
- filename = line.strip()
- if os.path.isfile(filename):
- self.append(filename)
- f.close()
+ def __init__(self):
+ f = os.popen('svn list -R')
+ for line in f.readlines():
+ filename = line.strip()
+ if os.path.isfile(filename):
+ self.append(filename)
+ f.close()
class _GitFileList(list):
- def __init__(self):
- f = os.popen('git-ls-files')
- for line in f.readlines():
- filename = line.strip()
- if not filename.startswith('.'):
- self.append(filename)
- f.close()
+ def __init__(self):
+ f = os.popen('git-ls-files')
+ for line in f.readlines():
+ filename = line.strip()
+ if not filename.startswith('.'):
+ self.append(filename)
+ f.close()
def _extract_bundle(source_file, dest_dir):
- if not os.path.exists(dest_dir):
- os.mkdir(dest_dir)
+ if not os.path.exists(dest_dir):
+ os.mkdir(dest_dir)
- zf = zipfile.ZipFile(source_file)
+ zf = zipfile.ZipFile(source_file)
- for i, name in enumerate(zf.namelist()):
- path = os.path.join(dest_dir, name)
-
- if not os.path.exists(os.path.dirname(path)):
- os.makedirs(os.path.dirname(path))
+ for i, name in enumerate(zf.namelist()):
+ path = os.path.join(dest_dir, name)
+
+ if not os.path.exists(os.path.dirname(path)):
+ os.makedirs(os.path.dirname(path))
- outfile = open(path, 'wb')
- outfile.write(zf.read(name))
- outfile.flush()
- outfile.close()
+ outfile = open(path, 'wb')
+ outfile.write(zf.read(name))
+ outfile.flush()
+ outfile.close()
def _get_source_path():
- return os.getcwd()
+ return os.getcwd()
def _get_activities_path():
- path = os.path.expanduser('~/Activities')
- if not os.path.isdir(path):
- os.mkdir(path)
- return path
+ path = os.path.expanduser('~/Activities')
+ if not os.path.isdir(path):
+ os.mkdir(path)
+ return path
def _get_bundle_dir():
- bundle_name = os.path.basename(_get_source_path())
- return bundle_name + '.activity'
+ bundle_name = os.path.basename(_get_source_path())
+ return bundle_name + '.activity'
def _get_install_dir(prefix):
- return os.path.join(prefix, 'share/activities')
+ return os.path.join(prefix, 'share/activities')
def _get_bundle_path():
- return os.path.join(_get_activities_path(), _get_bundle_dir())
+ return os.path.join(_get_activities_path(), _get_bundle_dir())
def _get_package_name():
- bundle = Bundle(_get_source_path())
- zipname = '%s-%d.xo' % (bundle.get_name(), bundle.get_activity_version())
- return zipname
+ bundle = Bundle(_get_source_path())
+ zipname = '%s-%d.xo' % (bundle.get_name(), bundle.get_activity_version())
+ return zipname
def _delete_backups(arg, dirname, names):
- for name in names:
- if name.endswith('~') or name.endswith('pyc'):
- os.remove(os.path.join(dirname, name))
+ for name in names:
+ if name.endswith('~') or name.endswith('pyc'):
+ os.remove(os.path.join(dirname, name))
def cmd_help():
- print 'Usage: \n\
+ print 'Usage: \n\
setup.py dev - setup for development \n\
setup.py dist - create a bundle package \n\
setup.py install - install the bundle \n\
@@ -98,59 +98,59 @@ setup.py help - print this message \n\
'
def cmd_dev():
- bundle_path = get_bundle_path()
- try:
- os.symlink(_get_source_path(), bundle_path)
- except OSError:
- if os.path.islink(bundle_path):
- print 'ERROR - The bundle has been already setup for development.'
- else:
- print 'ERROR - A bundle with the same name is already installed.'
+ bundle_path = get_bundle_path()
+ try:
+ os.symlink(_get_source_path(), bundle_path)
+ except OSError:
+ if os.path.islink(bundle_path):
+ print 'ERROR - The bundle has been already setup for development.'
+ else:
+ print 'ERROR - A bundle with the same name is already installed.'
def cmd_dist():
- if os.path.isdir('.git'):
- file_list = _GitFileList()
- elif os.path.isdir('.svn'):
- file_list = _SvnFileList()
- else:
- print 'ERROR - The command works only with git or svn repositories.'
-
- zipname = _get_package_name()
- bundle_zip = zipfile.ZipFile(zipname, 'w', zipfile.ZIP_DEFLATED)
-
- for filename in file_list:
- arcname = os.path.join(_get_bundle_dir(), filename)
- bundle_zip.write(filename, arcname)
-
- bundle_zip.close()
+ if os.path.isdir('.git'):
+ file_list = _GitFileList()
+ elif os.path.isdir('.svn'):
+ file_list = _SvnFileList()
+ else:
+ print 'ERROR - The command works only with git or svn repositories.'
+
+ zipname = _get_package_name()
+ bundle_zip = zipfile.ZipFile(zipname, 'w', zipfile.ZIP_DEFLATED)
+
+ for filename in file_list:
+ arcname = os.path.join(_get_bundle_dir(), filename)
+ bundle_zip.write(filename, arcname)
+
+ bundle_zip.close()
def cmd_install(prefix):
- cmd_dist()
- cmd_uninstall(prefix)
- _extract_bundle(_get_package_name(), _get_install_dir(prefix))
+ cmd_dist()
+ cmd_uninstall(prefix)
+ _extract_bundle(_get_package_name(), _get_install_dir(prefix))
def cmd_uninstall(prefix):
- path = os.path.join(_get_install_dir(prefix), _get_bundle_dir())
- if os.path.isdir(path):
- shutil.rmtree(path)
+ path = os.path.join(_get_install_dir(prefix), _get_bundle_dir())
+ if os.path.isdir(path):
+ shutil.rmtree(path)
def cmd_clean():
- os.path.walk('.', delete_backups, None)
+ os.path.walk('.', delete_backups, None)
def start():
- if len(sys.argv) < 2:
- cmd_help()
- elif sys.argv[1] == 'build':
- pass
- elif sys.argv[1] == 'dev':
- cmd_dev()
- elif sys.argv[1] == 'dist':
- cmd_dist()
- elif sys.argv[1] == 'install' and len(sys.argv) == 3:
- cmd_install(sys.argv[2])
- elif sys.argv[1] == 'uninstall' and len(sys.argv) == 3:
- cmd_uninstall(sys.argv[2])
- elif sys.argv[1] == 'clean':
- cmd_clean()
- else:
- cmd_help()
+ if len(sys.argv) < 2:
+ cmd_help()
+ elif sys.argv[1] == 'build':
+ pass
+ elif sys.argv[1] == 'dev':
+ cmd_dev()
+ elif sys.argv[1] == 'dist':
+ cmd_dist()
+ elif sys.argv[1] == 'install' and len(sys.argv) == 3:
+ cmd_install(sys.argv[2])
+ elif sys.argv[1] == 'uninstall' and len(sys.argv) == 3:
+ cmd_uninstall(sys.argv[2])
+ elif sys.argv[1] == 'clean':
+ cmd_clean()
+ else:
+ cmd_help()
diff --git a/sugar/activity/bundleregistry.py b/sugar/activity/bundleregistry.py
index f9adbca..aa7d70a 100644
--- a/sugar/activity/bundleregistry.py
+++ b/sugar/activity/bundleregistry.py
@@ -6,51 +6,51 @@ from sugar import env
from sugar import util
class _ServiceManager(object):
- def __init__(self):
- self._path = env.get_user_service_dir()
+ def __init__(self):
+ self._path = env.get_user_service_dir()
- def add(self, bundle):
- name = bundle.get_service_name()
+ 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()
+ # 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(name, full_exec, self._path)
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"""
- if self._bundles.has_key(service_name):
- return self._bundles[service_name]
- else:
- return None
-
- def add_search_path(self, path):
- """Add a directory to the bundles search path"""
- self._search_path.append(path)
- self._scan_directory(path)
-
- def __iter__(self):
- return self._bundles.values().__iter__()
-
- def _scan_directory(self, path):
- if os.path.isdir(path):
- for f in os.listdir(path):
- bundle_dir = os.path.join(path, f)
- if os.path.isdir(bundle_dir) and \
- bundle_dir.endswith('.activity'):
- self._add_bundle(bundle_dir)
-
- def _add_bundle(self, bundle_path):
- bundle = Bundle(bundle_path)
- if bundle.is_valid():
- self._bundles[bundle.get_service_name()] = bundle
- self._service_manager.add(bundle)
+ """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"""
+ if self._bundles.has_key(service_name):
+ return self._bundles[service_name]
+ else:
+ return None
+
+ def add_search_path(self, path):
+ """Add a directory to the bundles search path"""
+ self._search_path.append(path)
+ self._scan_directory(path)
+
+ def __iter__(self):
+ return self._bundles.values().__iter__()
+
+ def _scan_directory(self, path):
+ if os.path.isdir(path):
+ for f in os.listdir(path):
+ bundle_dir = os.path.join(path, f)
+ if os.path.isdir(bundle_dir) and \
+ bundle_dir.endswith('.activity'):
+ self._add_bundle(bundle_dir)
+
+ def _add_bundle(self, bundle_path):
+ bundle = Bundle(bundle_path)
+ if bundle.is_valid():
+ self._bundles[bundle.get_service_name()] = bundle
+ self._service_manager.add(bundle)