fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
update memcached in fabfile
[wolnelektury.git]
/
src
/
search
/
management
/
commands
/
reindex.py
diff --git
a/src/search/management/commands/reindex.py
b/src/search/management/commands/reindex.py
index
4941354
..
b8cb49c
100755
(executable)
--- a/
src/search/management/commands/reindex.py
+++ b/
src/search/management/commands/reindex.py
@@
-3,10
+3,13
@@
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
import sys
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
import sys
+import traceback
+
from django.core.management.base import BaseCommand
from optparse import make_option
from django.core.management.base import BaseCommand
from optparse import make_option
+
def query_yes_no(question, default="yes"):
"""Ask a yes/no question via raw_input() and return their answer.
def query_yes_no(question, default="yes"):
"""Ask a yes/no question via raw_input() and return their answer.
@@
-17,9
+20,9
@@
def query_yes_no(question, default="yes"):
The "answer" return value is one of "yes" or "no".
"""
The "answer" return value is one of "yes" or "no".
"""
- valid = {"yes":
True, "y":True, "ye":
True,
- "no":
False, "n":
False}
- if default
==
None:
+ valid = {"yes":
True, "y": True, "ye":
True,
+ "no":
False, "n":
False}
+ if default
is
None:
prompt = " [y/n] "
elif default == "yes":
prompt = " [Y/n] "
prompt = " [y/n] "
elif default == "yes":
prompt = " [Y/n] "
@@
-36,8
+39,8
@@
def query_yes_no(question, default="yes"):
elif choice in valid:
return valid[choice]
else:
elif choice in valid:
return valid[choice]
else:
- sys.stdout.write("Please respond with 'yes' or 'no'
"\
- "(or 'y' or 'n').\n")
+ sys.stdout.write("Please respond with 'yes' or 'no'
(or 'y' or 'n').\n")
+
class Command(BaseCommand):
help = 'Reindex everything.'
class Command(BaseCommand):
help = 'Reindex everything.'
@@
-45,10
+48,11
@@
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option('-n', '--book-id', action='store_true', dest='book_id', default=False,
option_list = BaseCommand.option_list + (
make_option('-n', '--book-id', action='store_true', dest='book_id', default=False,
- help='book id instead of slugs'),
+
help='book id instead of slugs'),
make_option('-t', '--just-tags', action='store_true', dest='just_tags', default=False,
make_option('-t', '--just-tags', action='store_true', dest='just_tags', default=False,
- help='just reindex tags'),
+
help='just reindex tags'),
)
)
+
def handle(self, *args, **opts):
from catalogue.models import Book
from search.index import Index
def handle(self, *args, **opts):
from catalogue.models import Book
from search.index import Index
@@
-72,8
+76,8
@@
class Command(BaseCommand):
idx.index_book(b)
idx.index.commit()
books.pop(0)
idx.index_book(b)
idx.index.commit()
books.pop(0)
- except
Exception, e
:
- print "Error occured: %s" % e
+ except:
+ traceback.print_exc()
try:
# we might not be able to rollback
idx.index.rollback()
try:
# we might not be able to rollback
idx.index.rollback()