comparison pylons_app/lib/indexers/daemon.py @ 452:f19d3ee89335

updated whoosh indexer to take path as second argument
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 03 Sep 2010 13:15:16 +0200
parents d726f62f886e
children e01a85f9fc90
comparison
equal deleted inserted replaced
451:d726f62f886e 452:f19d3ee89335
183 else: 183 else:
184 self.update_index() 184 self.update_index()
185 185
186 if __name__ == "__main__": 186 if __name__ == "__main__":
187 arg = sys.argv[1:] 187 arg = sys.argv[1:]
188 if not arg: 188 if len(arg) != 2:
189 sys.stdout.write('Please specify indexing type [full|incremental]' 189 sys.stderr.write('Please specify indexing type [full|incremental]'
190 ' as script arg \n') 190 'and path to repositories as script args \n')
191 sys.exit() 191 sys.exit()
192
193
192 if arg[0] == 'full': 194 if arg[0] == 'full':
193 full_index = True 195 full_index = True
194 elif arg[0] == 'incremental': 196 elif arg[0] == 'incremental':
195 # False means looking just for changes 197 # False means looking just for changes
196 full_index = False 198 full_index = False
197 else: 199 else:
198 sys.stdout.write('Please use [full|incremental]' 200 sys.stdout.write('Please use [full|incremental]'
199 ' as script arg \n') 201 ' as script first arg \n')
200 sys.exit() 202 sys.exit()
201 203
202 204 if not os.path.isdir(arg[1]):
203 repo_location = '/home/hg_repos/*' 205 sys.stderr.write('%s is not a valid path \n' % arg[1])
206 sys.exit()
207 else:
208 if arg[1].endswith('/'):
209 repo_location = arg[1] + '*'
210 else:
211 repo_location = arg[1] + '/*'
204 212
205 try: 213 try:
206 l = DaemonLock() 214 l = DaemonLock()
207 WhooshIndexingDaemon(repo_location=repo_location)\ 215 WhooshIndexingDaemon(repo_location=repo_location)\
208 .run(full_index=full_index) 216 .run(full_index=full_index)