Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknown <unknown@unknown.org>2010-11-01 16:52:57 (GMT)
committer Sascha Silbe <sascha-pgp@silbe.org>2010-11-01 16:52:57 (GMT)
commitac60c55b00eb0b8a46a36f2a35447f644d6b9351 (patch)
tree86ec0b8209655426f11ab2dbc5c863a62515dcf2
parentacb3ab67c81ba7bd985f375fce5647280b64cf73 (diff)
journal-0002-reindex.patch
-rw-r--r--bin/Makefile.am3
-rw-r--r--bin/journal-reindex39
-rw-r--r--src/jarabe/journal/processdialog.py19
-rw-r--r--src/jarabe/view/palettes.py18
4 files changed, 77 insertions, 2 deletions
diff --git a/bin/Makefile.am b/bin/Makefile.am
index 8cc87b5..b0be3d9 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -7,7 +7,8 @@ python_scripts = \
sugar-session \
sugar-ui-check \
journal-backup-volume \
- journal-restore-volume
+ journal-restore-volume \
+ journal-reindex
bin_SCRIPTS = \
sugar \
diff --git a/bin/journal-reindex b/bin/journal-reindex
new file mode 100644
index 0000000..29e64ff
--- /dev/null
+++ b/bin/journal-reindex
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+# Copyright (C) 2010, Plan Ceibal <comunidad@plan.ceibal.edu.uy>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import os
+import subprocess
+from gettext import gettext as _
+from sugar import env
+import logging
+
+logging.debug('Reindex started')
+
+reindex_file = os.path.join(env.get_profile_path(), 'datastore/index_updated')
+
+subprocess.call(['pkill', '-9', '-f', 'python.*datastore-service'])
+
+if os.path.exists(reindex_file):
+ result = 0
+ try:
+ os.remove(reindex_file)
+ except Exception, e:
+ logging.error(_('Reindex failed: %s'), str(e))
+ result = 1
+
+logging.debug('Reindex finished')
+exit(result)
diff --git a/src/jarabe/journal/processdialog.py b/src/jarabe/journal/processdialog.py
index 181174d..4c744cb 100644
--- a/src/jarabe/journal/processdialog.py
+++ b/src/jarabe/journal/processdialog.py
@@ -293,3 +293,22 @@ class XSRestoreDialog(ProcessDialog):
def _check_prerequisites(self):
return len(shell.get_model()) <= 1
+
+class ReindexDialog(ProcessDialog):
+ def __init__(self):
+ ProcessDialog.__init__(self, 'journal-reindex')
+ self._resetup_information()
+
+ def _resetup_information(self):
+ self._start_message = '%s.' % (_('Please wait, repair journal content'))
+
+ self._finished_message = _('The journal content has been reindexed.')
+
+ self._title.set_markup('<big><b>%s</b></big>' % _('Repair'))
+
+ self._message.set_text('%s.' % (_('Journal content will be repaired')))
+
+ self._prerequisite_message = _(', please close all the running activities.')
+
+ def _check_prerequisites(self):
+ return len(shell.get_model()) <= 1
diff --git a/src/jarabe/view/palettes.py b/src/jarabe/view/palettes.py
index 51c40f1..5994c3d 100644
--- a/src/jarabe/view/palettes.py
+++ b/src/jarabe/view/palettes.py
@@ -33,7 +33,7 @@ from sugar.graphics.xocolor import XoColor
from sugar.activity import activityfactory
from sugar.activity.activityhandle import ActivityHandle
-from jarabe.journal.processdialog import VolumeBackupDialog, VolumeRestoreDialog, XSBackupDialog, XSRestoreDialog
+from jarabe.journal.processdialog import VolumeBackupDialog, VolumeRestoreDialog, XSBackupDialog, XSRestoreDialog, ReindexDialog
from jarabe.model import shell
from jarabe.view import launcher
from jarabe.view.viewsource import setup_view_source
@@ -198,6 +198,22 @@ class JournalPalette(BasePalette):
self.menu.append(menu_item)
menu_item.show()
+ menu_item_reindex = MenuItem(_('Repair'))
+
+ icon_reindex = Icon(icon_name='journal-reindex',
+ icon_size=gtk.ICON_SIZE_MENU)
+ menu_item_reindex.set_image(icon_reindex)
+ icon_reindex.show()
+
+ menu_item_reindex.connect('activate', self.__reindex_activate_cb)
+ self.menu.append(menu_item_reindex)
+ menu_item_reindex.show()
+
+ def __reindex_activate_cb(self, menu_item):
+ dialog = ReindexDialog()
+ dialog.show()
+
+
def __open_activate_cb(self, menu_item):
self._home_activity.get_window().activate(gtk.get_current_event_time())