Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erase bundle fixes #687

Merged
merged 2 commits into from Jun 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/Makefile.am
Expand Up @@ -4,6 +4,7 @@ python_scripts = \
sugar-backlight-setup \
sugar-control-panel \
sugar-install-bundle \
sugar-erase-bundle \
sugar-launch

bin_SCRIPTS = \
Expand Down
25 changes: 25 additions & 0 deletions bin/sugar-erase-bundle
@@ -0,0 +1,25 @@
#!/usr/bin/env python2
import os
import sys

from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)

from jarabe.model import bundleregistry

def cmd_help():
print 'Usage: sugar-erase-bundle bundle_id [...] \n\n\
Erase activity bundles\n'

if len(sys.argv) < 2:
cmd_help()
exit(2)

for name in sys.argv[1:]:
registry = bundleregistry.get_registry()
bundle = registry.get_bundle(name)
if not bundle:
print 'Cannot find %s bundle.' % name
continue

registry.uninstall(bundle, delete_profile=True)
18 changes: 18 additions & 0 deletions src/jarabe/model/bundleregistry.py
Expand Up @@ -140,6 +140,24 @@ def __file_monitor_changed_cb(self, monitor, one_file, other_file,
self.add_bundle(one_file.get_path(), set_favorite=True)
elif event_type == Gio.FileMonitorEvent.DELETED:
self.remove_bundle(one_file.get_path())
for root in GLib.get_system_data_dirs():
root = os.path.join(root, 'sugar', 'activities')

try:
dir_list = os.listdir(root)
except OSError:
logging.debug('Can not find GLib system dir %s', root)
continue
activity_dir = os.path.basename(one_file.get_path())
try:
bundle = bundle_from_dir(os.path.join(root, activity_dir))
except MalformedBundleException:
continue

if bundle is not None:
path = bundle.get_path()
if path is not None:
self.add_bundle(path)

def _load_mime_defaults(self):
defaults = {}
Expand Down