Mercurial > kallithea
comparison pylons_app/lib/indexers/daemon.py @ 483:a9e50dce3081 celery
Removed config names from whoosh and celery,
celery is now configured based on the config name it's using
on celeryconfig. And whoosh uses it's own logger configured just for whoosh
Test creates a fresh whoosh index now, for more accurate checks
fixed tests for searching
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 17 Sep 2010 22:54:30 +0200 |
parents | e01a85f9fc90 |
children | fefffd6fd5f4 |
comparison
equal
deleted
inserted
replaced
482:7afbc45aab28 | 483:a9e50dce3081 |
---|---|
31 #to get the pylons_app import | 31 #to get the pylons_app import |
32 project_path = dn(dn(dn(dn(os.path.realpath(__file__))))) | 32 project_path = dn(dn(dn(dn(os.path.realpath(__file__))))) |
33 sys.path.append(project_path) | 33 sys.path.append(project_path) |
34 | 34 |
35 from pidlock import LockHeld, DaemonLock | 35 from pidlock import LockHeld, DaemonLock |
36 import traceback | |
37 from pylons_app.config.environment import load_environment | |
38 from pylons_app.model.hg_model import HgModel | 36 from pylons_app.model.hg_model import HgModel |
39 from pylons_app.lib.helpers import safe_unicode | 37 from pylons_app.lib.helpers import safe_unicode |
40 from whoosh.index import create_in, open_dir | 38 from whoosh.index import create_in, open_dir |
41 from shutil import rmtree | 39 from shutil import rmtree |
42 from pylons_app.lib.indexers import ANALYZER, INDEX_EXTENSIONS, IDX_LOCATION, \ | 40 from pylons_app.lib.indexers import INDEX_EXTENSIONS, IDX_LOCATION, SCHEMA, IDX_NAME |
43 SCHEMA, IDX_NAME | |
44 | 41 |
45 import logging | 42 import logging |
46 import logging.config | 43 |
47 logging.config.fileConfig(jn(project_path, 'development.ini')) | |
48 log = logging.getLogger('whooshIndexer') | 44 log = logging.getLogger('whooshIndexer') |
45 # create logger | |
46 log.setLevel(logging.DEBUG) | |
47 | |
48 # create console handler and set level to debug | |
49 ch = logging.StreamHandler() | |
50 ch.setLevel(logging.DEBUG) | |
51 | |
52 # create formatter | |
53 formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") | |
54 | |
55 # add formatter to ch | |
56 ch.setFormatter(formatter) | |
57 | |
58 # add ch to logger | |
59 log.addHandler(ch) | |
49 | 60 |
50 def scan_paths(root_location): | 61 def scan_paths(root_location): |
51 return HgModel.repo_scan('/', root_location, None, True) | 62 return HgModel.repo_scan('/', root_location, None, True) |
52 | 63 |
53 class WhooshIndexingDaemon(object): | 64 class WhooshIndexingDaemon(object): |
219 try: | 230 try: |
220 l = DaemonLock() | 231 l = DaemonLock() |
221 WhooshIndexingDaemon(repo_location=repo_location)\ | 232 WhooshIndexingDaemon(repo_location=repo_location)\ |
222 .run(full_index=full_index) | 233 .run(full_index=full_index) |
223 l.release() | 234 l.release() |
235 reload(logging) | |
224 except LockHeld: | 236 except LockHeld: |
225 sys.exit(1) | 237 sys.exit(1) |
226 | 238 |