Improve bundle API for bundleregistry changes

The bundle API is a bit confusing and inconsistent. Fix up the
ActivityBundle and ContentBundle classes to be more consistent and to
work with the ongoing improvements being made in bundleregistry.
master
Daniel Drake 11 years ago committed by Daniel Narvaez
parent f4c1bd152a
commit 12476caa12

@ -226,10 +226,6 @@ class ActivityBundle(Bundle):
raise NotInstalledException raise NotInstalledException
return os.path.join(self._path, 'icons') return os.path.join(self._path, 'icons')
def get_path(self):
"""Get the activity bundle path."""
return self._path
def get_name(self): def get_name(self):
"""Get the activity user-visible name.""" """Get the activity user-visible name."""
return self._name return self._name
@ -287,9 +283,8 @@ class ActivityBundle(Bundle):
"""Get whether there should be a visible launcher for the activity""" """Get whether there should be a visible launcher for the activity"""
return self._show_launcher return self._show_launcher
def install(self, install_dir=None): def install(self):
if install_dir is None: install_dir = env.get_user_activities_path()
install_dir = env.get_user_activities_path()
self._unzip(install_dir) self._unzip(install_dir)
@ -348,7 +343,9 @@ class ActivityBundle(Bundle):
os.unlink(dst) os.unlink(dst)
os.symlink(src, dst) os.symlink(src, dst)
def uninstall(self, install_path, force=False, delete_profile=False): def uninstall(self, force=False, delete_profile=False):
install_path = self.get_path()
if os.path.islink(install_path): if os.path.islink(install_path):
# Don't remove the actual activity dir if it's a symbolic link # Don't remove the actual activity dir if it's a symbolic link
# because we may be removing user data. # because we may be removing user data.

@ -26,8 +26,7 @@ import os
import urllib import urllib
from sugar3 import env from sugar3 import env
from sugar3.bundle.bundle import Bundle, NotInstalledException, \ from sugar3.bundle.bundle import Bundle, MalformedBundleException
MalformedBundleException
from sugar3.bundle.bundleversion import NormalizedVersion from sugar3.bundle.bundleversion import NormalizedVersion
from sugar3.bundle.bundleversion import InvalidVersionError from sugar3.bundle.bundleversion import InvalidVersionError
@ -185,6 +184,10 @@ class ContentBundle(Bundle):
def get_activity_start(self): def get_activity_start(self):
return self._activity_start return self._activity_start
def get_icon(self):
# To be implemented later
return None
def _run_indexer(self): def _run_indexer(self):
xdg_data_dirs = os.getenv('XDG_DATA_DIRS', xdg_data_dirs = os.getenv('XDG_DATA_DIRS',
'/usr/local/share/:/usr/share/') '/usr/local/share/:/usr/share/')
@ -215,29 +218,17 @@ class ContentBundle(Bundle):
# needs rethinking while fixing ContentBundle support # needs rethinking while fixing ContentBundle support
return self._library_version return self._library_version
def is_installed(self):
if self._zip_file is None:
return True
elif os.path.isdir(self.get_root_dir()):
return ContentBundle(self.get_root_dir()).get_library_version() \
== self.get_library_version()
else:
return False
def install(self): def install(self):
# TODO ignore passed install_path argument
# needs rethinking while fixing ContentBundle support
install_path = env.get_user_library_path() install_path = env.get_user_library_path()
self._unzip(install_path) self._unzip(install_path)
self._run_indexer() self._run_indexer()
return self.get_root_dir() return self.get_root_dir()
def uninstall(self): def uninstall(self, force=False, delete_profile=False):
if self._zip_file is None: install_dir = self._path
if not self.is_installed():
raise NotInstalledException
install_dir = self._path
else:
install_dir = os.path.join(self.get_root_dir())
self._uninstall(install_dir) self._uninstall(install_dir)
self._run_indexer() self._run_indexer()
def is_user_activity(self):
# All content bundles are installed in user storage
return True

Loading…
Cancel
Save