[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GMG-Devel] [PATCH 38/83] Add gmg command to delete all indices.
From: |
Alon Levy |
Subject: |
[GMG-Devel] [PATCH 38/83] Add gmg command to delete all indices. |
Date: |
Tue, 25 Feb 2014 21:58:21 +0200 |
From: Praveen Kumar <address@hidden>
---
mediagoblin/gmg_commands/__init__.py | 4 ++++
mediagoblin/gmg_commands/search.py | 13 +++++++++++++
mediagoblin/plugins/search/utils.py | 24 ++++++++++++++++++++++++
3 files changed, 41 insertions(+)
create mode 100644 mediagoblin/gmg_commands/search.py
create mode 100644 mediagoblin/plugins/search/utils.py
diff --git a/mediagoblin/gmg_commands/__init__.py
b/mediagoblin/gmg_commands/__init__.py
index a1eb599..c082e52 100644
--- a/mediagoblin/gmg_commands/__init__.py
+++ b/mediagoblin/gmg_commands/__init__.py
@@ -53,6 +53,10 @@ SUBCOMMAND_MAP = {
'setup': 'mediagoblin.gmg_commands.addmedia:parser_setup',
'func': 'mediagoblin.gmg_commands.addmedia:addmedia',
'help': 'Reprocess media entries'},
+ 'delete_all_indices': {
+ 'setup': 'mediagoblin.gmg_commands.search:search_parser_setup',
+ 'func': 'mediagoblin.gmg_commands.search:delete_all_indices',
+ 'help': 'Delete all existing indices'},
# 'theme': {
# 'setup': 'mediagoblin.gmg_commands.theme:theme_parser_setup',
# 'func': 'mediagoblin.gmg_commands.theme:theme',
diff --git a/mediagoblin/gmg_commands/search.py
b/mediagoblin/gmg_commands/search.py
new file mode 100644
index 0000000..5ed4de1
--- /dev/null
+++ b/mediagoblin/gmg_commands/search.py
@@ -0,0 +1,13 @@
+import logging
+
+from mediagoblin.plugins.search import utils
+
+_log = logging.getLogger(__name__)
+
+
+def search_parser_setup(subparser):
+ pass
+
+def delete_all_indices(args):
+ _log.info("Deleting indices...")
+ utils.delete_all_indices()
diff --git a/mediagoblin/plugins/search/utils.py
b/mediagoblin/plugins/search/utils.py
new file mode 100644
index 0000000..761ba58
--- /dev/null
+++ b/mediagoblin/plugins/search/utils.py
@@ -0,0 +1,24 @@
+import logging
+import shutil
+
+from subprocess import call
+
+from mediagoblin.plugins import search
+
+
+_log = logging.getLogger(__name__)
+
+
+def delete_all_indices():
+ all_indices = search.registry.IndexRegistry.indices()
+
+ for index in all_indices.itervalues():
+ index_dir = index.search_index_dir
+ call(['rm -r %s'%(index_dir)], shell=True)
+ _log.info("Deleting index for %s stored in %s"%(
+ index.model.__class__.__name__, index_dir))
+
+
+def create_all_indices():
+ search.register_indices()
+
--
1.8.5.3
- [GMG-Devel] [PATCH 28/83] Fix bugs, (continued)
- [GMG-Devel] [PATCH 28/83] Fix bugs, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 29/83] Add methods to interpret results by the SearchIndex object, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 30/83] fix parameters in search views, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 31/83] Refactor SearchIndex and add method to update an index., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 32/83] Add event listener for model update, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 33/83] Add listener for model delete event., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 34/83] Fix bugs in SearchIndex, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 35/83] Add indices for MediaEntry and MediaTag., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 36/83] Add schema for MediaTag., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 37/83] Register schemas for MediaEntry and MediaTag., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 38/83] Add gmg command to delete all indices.,
Alon Levy <=
- [GMG-Devel] [PATCH 39/83] Clean up and add docstring to search methods., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 40/83] Add try-except block to event listeners., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 42/83] Store attributes from a model only it its available., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 43/83] Add field for storing search results., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 41/83] Correct method names in event listeners, Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 44/83] Remove the field for storing search results with the index., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 46/83] Add verbose_name and css_id to search results., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 47/83] Adapt results collection to change in result generation., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 48/83] Modify search template to show tabbed results., Alon Levy, 2014/02/25
- [GMG-Devel] [PATCH 49/83] Show only unique results., Alon Levy, 2014/02/25