comparison rhodecode/lib/indexers/__init__.py @ 683:341beaa9edba beta

Implemented whoosh index building as paster command. docs update fixed manifest.in for missing yui file. Fixed setup to beta added base for paster upgrade-db command
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 13 Nov 2010 02:29:46 +0100
parents 05528ad948c4
children b9442a8b5e02
comparison
equal deleted inserted replaced
682:23c2a0e6df0b 683:341beaa9edba
57 max_args = 1 57 max_args = 1
58 min_args = 1 58 min_args = 1
59 59
60 usage = "CONFIG_FILE" 60 usage = "CONFIG_FILE"
61 summary = "Creates index for full text search given configuration file" 61 summary = "Creates index for full text search given configuration file"
62 group_name = "Whoosh indexing" 62 group_name = "RhodeCode"
63 63 takes_config_file = -1
64 parser = command.Command.standard_parser(verbose=True) 64 parser = command.Command.standard_parser(verbose=True)
65 # parser.add_option('--repo-location', 65 parser.add_option('--repo-location',
66 # action='store', 66 action='store',
67 # dest='repo_location', 67 dest='repo_location',
68 # help="Specifies repositories location to index", 68 help="Specifies repositories location to index REQUIRED",
69 # ) 69 )
70 parser.add_option('-f', 70 parser.add_option('-f',
71 action='store_true', 71 action='store_true',
72 dest='full_index', 72 dest='full_index',
73 help="Specifies that index should be made full i.e" 73 help="Specifies that index should be made full i.e"
74 " destroy old and build from scratch", 74 " destroy old and build from scratch",
75 default=False) 75 default=False)
76 def command(self): 76 def command(self):
77 config_name = self.args[0] 77 config_name = self.args[0]
78
79 p = config_name.split('/') 78 p = config_name.split('/')
80 if len(p) == 1: 79 root = '.' if len(p) == 1 else '/'.join(p[:-1])
81 root = '.'
82 else:
83 root = '/'.join(p[:-1])
84 print root
85 config = ConfigParser.ConfigParser({'here':root}) 80 config = ConfigParser.ConfigParser({'here':root})
86 config.read(config_name) 81 config.read(config_name)
87 print dict(config.items('app:main'))['index_dir'] 82
88 index_location = dict(config.items('app:main'))['index_dir'] 83 index_location = dict(config.items('app:main'))['index_dir']
89 #return 84 repo_location = self.options.repo_location
90 85
91 #======================================================================= 86 #======================================================================
92 # WHOOSH DAEMON 87 # WHOOSH DAEMON
93 #======================================================================= 88 #======================================================================
94 from rhodecode.lib.pidlock import LockHeld, DaemonLock 89 from rhodecode.lib.pidlock import LockHeld, DaemonLock
95 from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon 90 from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon
96 try: 91 try:
97 l = DaemonLock() 92 l = DaemonLock()
98 WhooshIndexingDaemon(index_location=index_location)\ 93 WhooshIndexingDaemon(index_location=index_location,
94 repo_location=repo_location)\
99 .run(full_index=self.options.full_index) 95 .run(full_index=self.options.full_index)
100 l.release() 96 l.release()
101 except LockHeld: 97 except LockHeld:
102 sys.exit(1) 98 sys.exit(1)
103 99