|
1 # |
|
2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net> |
|
3 # All Rights Reserved. |
|
4 # |
|
5 # This software is subject to the provisions of the Zope Public License, |
|
6 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. |
|
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
|
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
|
10 # FOR A PARTICULAR PURPOSE. |
|
11 # |
|
12 |
|
13 __docformat__ = 'restructuredtext' |
|
14 |
|
15 |
|
16 # import standard library |
|
17 import argparse |
|
18 import sys |
|
19 import textwrap |
|
20 |
|
21 # import interfaces |
|
22 |
|
23 # import packages |
|
24 from pyams_content_es.site import site_index |
|
25 from pyramid.paster import bootstrap |
|
26 |
|
27 |
|
28 def index_site(): |
|
29 """Update all ElasticSearch indexes""" |
|
30 usage = "usage: {0} config_uri".format(sys.argv[0]) |
|
31 description = """Update all ElasticSearch indexes with all database contents.""" |
|
32 |
|
33 parser = argparse.ArgumentParser(usage=usage, |
|
34 description=textwrap.dedent(description)) |
|
35 parser.add_argument('config_uri', help='Name of configuration file') |
|
36 args = parser.parse_args() |
|
37 |
|
38 config_uri = args.config_uri |
|
39 env = bootstrap(config_uri) |
|
40 settings, closer = env['registry'].settings, env['closer'] |
|
41 try: |
|
42 site_index(env['request']) |
|
43 finally: |
|
44 closer() |