Mercurial > public > src > rhodecode
comparison pylons_app/lib/celerylib/tasks.py @ 527: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 | a3d9d24acbec |
children | 5c376ac2d4c9 |
comparison
equal
deleted
inserted
replaced
526:7afbc45aab28 | 527:a9e50dce3081 |
---|---|
1 from celery.decorators import task | 1 from celery.decorators import task |
2 from celery.task.sets import subtask | 2 from celery.task.sets import subtask |
3 from celeryconfig import PYLONS_CONFIG as config | |
3 from datetime import datetime, timedelta | 4 from datetime import datetime, timedelta |
4 from os.path import dirname as dn | |
5 from pylons.i18n.translation import _ | 5 from pylons.i18n.translation import _ |
6 from pylons_app.lib.celerylib import run_task | 6 from pylons_app.lib.celerylib import run_task |
7 from pylons_app.lib.helpers import person | 7 from pylons_app.lib.helpers import person |
8 from pylons_app.lib.smtp_mailer import SmtpMailer | 8 from pylons_app.lib.smtp_mailer import SmtpMailer |
9 from pylons_app.lib.utils import OrderedDict | 9 from pylons_app.lib.utils import OrderedDict |
10 from time import mktime | 10 from time import mktime |
11 from vcs.backends.hg import MercurialRepository | 11 from vcs.backends.hg import MercurialRepository |
12 import ConfigParser | |
13 import calendar | 12 import calendar |
14 import os | |
15 import traceback | 13 import traceback |
16 | |
17 | |
18 root = dn(dn(dn(dn(os.path.realpath(__file__))))) | |
19 config = ConfigParser.ConfigParser({'here':root}) | |
20 config.read('%s/development.ini' % root) | |
21 | 14 |
22 __all__ = ['whoosh_index', 'get_commits_stats', | 15 __all__ = ['whoosh_index', 'get_commits_stats', |
23 'reset_user_password', 'send_email'] | 16 'reset_user_password', 'send_email'] |
24 | 17 |
25 def get_session(): | 18 def get_session(): |
89 | 82 |
90 @task | 83 @task |
91 def get_commits_stats(repo): | 84 def get_commits_stats(repo): |
92 log = get_commits_stats.get_logger() | 85 log = get_commits_stats.get_logger() |
93 aggregate = OrderedDict() | 86 aggregate = OrderedDict() |
94 repos_path = get_hg_ui_settings()['paths_root_path'].replace('*','') | 87 repos_path = get_hg_ui_settings()['paths_root_path'].replace('*', '') |
95 repo = MercurialRepository(repos_path + repo) | 88 repo = MercurialRepository(repos_path + repo) |
96 #graph range | 89 #graph range |
97 td = datetime.today() + timedelta(days=1) | 90 td = datetime.today() + timedelta(days=1) |
98 y, m, d = td.year, td.month, td.day | 91 y, m, d = td.year, td.month, td.day |
99 ts_min = mktime((y, (td - timedelta(days=calendar.mdays[m])).month, | 92 ts_min = mktime((y, (td - timedelta(days=calendar.mdays[m])).month, |
203 mail_port = email_config.get('smtp_port') | 196 mail_port = email_config.get('smtp_port') |
204 tls = email_config.get('smtp_use_tls') | 197 tls = email_config.get('smtp_use_tls') |
205 ssl = False | 198 ssl = False |
206 | 199 |
207 try: | 200 try: |
208 m = SmtpMailer(mail_from, user, passwd, mail_server, | 201 m = SmtpMailer(mail_from, user, passwd, mail_server, |
209 mail_port, ssl, tls) | 202 mail_port, ssl, tls) |
210 m.send(recipients, subject, body) | 203 m.send(recipients, subject, body) |
211 except: | 204 except: |
212 log.error('Mail sending failed') | 205 log.error('Mail sending failed') |
213 log.error(traceback.format_exc()) | 206 log.error(traceback.format_exc()) |