comparison rhodecode/lib/indexers/__init__.py @ 2165:dc2584ba5fbc

merged beta into default branch
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 28 Mar 2012 19:54:16 +0200
parents 82a88013a3fd 8ecfed1d8f8b
children 63e58ef80ef1
comparison
equal deleted inserted replaced
2097:8fd6650bb436 2165:dc2584ba5fbc
23 # You should have received a copy of the GNU General Public License 23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. 24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 import os 25 import os
26 import sys 26 import sys
27 import traceback 27 import traceback
28 import logging
28 from os.path import dirname as dn, join as jn 29 from os.path import dirname as dn, join as jn
29 30
30 #to get the rhodecode import 31 #to get the rhodecode import
31 sys.path.append(dn(dn(dn(os.path.realpath(__file__))))) 32 sys.path.append(dn(dn(dn(os.path.realpath(__file__)))))
32 33
44 45
45 from rhodecode.model import init_model 46 from rhodecode.model import init_model
46 from rhodecode.model.scm import ScmModel 47 from rhodecode.model.scm import ScmModel
47 from rhodecode.model.repo import RepoModel 48 from rhodecode.model.repo import RepoModel
48 from rhodecode.config.environment import load_environment 49 from rhodecode.config.environment import load_environment
49 from rhodecode.lib import LANGUAGES_EXTENSIONS_MAP, LazyProperty 50 from rhodecode.lib.utils2 import LazyProperty
50 from rhodecode.lib.utils import BasePasterCommand, Command, add_cache 51 from rhodecode.lib.utils import BasePasterCommand, Command, add_cache,\
51 52 load_rcextensions
52 # EXTENSIONS WE WANT TO INDEX CONTENT OFF
53 INDEX_EXTENSIONS = LANGUAGES_EXTENSIONS_MAP.keys()
54 53
55 # CUSTOM ANALYZER wordsplit + lowercase filter 54 # CUSTOM ANALYZER wordsplit + lowercase filter
56 ANALYZER = RegexTokenizer(expression=r"\w+") | LowercaseFilter() 55 ANALYZER = RegexTokenizer(expression=r"\w+") | LowercaseFilter()
57 56
58 57
82 group_name = "RhodeCode" 81 group_name = "RhodeCode"
83 takes_config_file = -1 82 takes_config_file = -1
84 parser = Command.standard_parser(verbose=True) 83 parser = Command.standard_parser(verbose=True)
85 84
86 def command(self): 85 def command(self):
87 86 logging.config.fileConfig(self.path_to_ini_file)
88 from pylons import config 87 from pylons import config
89 add_cache(config) 88 add_cache(config)
90 engine = engine_from_config(config, 'sqlalchemy.db1.') 89 engine = engine_from_config(config, 'sqlalchemy.db1.')
91 init_model(engine) 90 init_model(engine)
92
93 index_location = config['index_dir'] 91 index_location = config['index_dir']
94 repo_location = self.options.repo_location \ 92 repo_location = self.options.repo_location \
95 if self.options.repo_location else RepoModel().repos_path 93 if self.options.repo_location else RepoModel().repos_path
96 repo_list = map(strip, self.options.repo_list.split(',')) \ 94 repo_list = map(strip, self.options.repo_list.split(',')) \
97 if self.options.repo_list else None 95 if self.options.repo_list else None
98 96 load_rcextensions(config['here'])
99 #====================================================================== 97 #======================================================================
100 # WHOOSH DAEMON 98 # WHOOSH DAEMON
101 #====================================================================== 99 #======================================================================
102 from rhodecode.lib.pidlock import LockHeld, DaemonLock 100 from rhodecode.lib.pidlock import LockHeld, DaemonLock
103 from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon 101 from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon
104 try: 102 try:
105 l = DaemonLock(file_=jn(dn(dn(index_location)), 'make_index.lock')) 103 l = DaemonLock(file_=jn(dn(dn(index_location)), 'make_index.lock'))
106 WhooshIndexingDaemon(index_location=index_location, 104 WhooshIndexingDaemon(index_location=index_location,
107 repo_location=repo_location, 105 repo_location=repo_location,
108 repo_list=repo_list)\ 106 repo_list=repo_list,)\
109 .run(full_index=self.options.full_index) 107 .run(full_index=self.options.full_index)
110 l.release() 108 l.release()
111 except LockHeld: 109 except LockHeld:
112 sys.exit(1) 110 sys.exit(1)
113 111