Mercurial > kallithea
comparison rhodecode/lib/celerylib/tasks.py @ 1401:b7563ad4e7ee beta
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 30 Jun 2011 01:25:37 +0200 |
parents | 9c0f5d558789 |
children | 5875955def39 |
comparison
equal
deleted
inserted
replaced
1400:0d7b56b97953 | 1401:b7563ad4e7ee |
---|---|
35 from string import lower | 35 from string import lower |
36 | 36 |
37 from pylons import config | 37 from pylons import config |
38 from pylons.i18n.translation import _ | 38 from pylons.i18n.translation import _ |
39 | 39 |
40 from rhodecode.lib import LANGUAGES_EXTENSIONS_MAP | 40 from rhodecode.lib import LANGUAGES_EXTENSIONS_MAP, safe_str |
41 from rhodecode.lib.celerylib import run_task, locked_task, str2bool, \ | 41 from rhodecode.lib.celerylib import run_task, locked_task, str2bool, \ |
42 __get_lockkey, LockHeld, DaemonLock | 42 __get_lockkey, LockHeld, DaemonLock |
43 from rhodecode.lib.helpers import person | 43 from rhodecode.lib.helpers import person |
44 from rhodecode.lib.smtp_mailer import SmtpMailer | 44 from rhodecode.lib.smtp_mailer import SmtpMailer |
45 from rhodecode.lib.utils import add_cache | 45 from rhodecode.lib.utils import add_cache |
64 'reset_user_password', 'send_email'] | 64 'reset_user_password', 'send_email'] |
65 | 65 |
66 CELERY_ON = str2bool(config['app_conf'].get('use_celery')) | 66 CELERY_ON = str2bool(config['app_conf'].get('use_celery')) |
67 | 67 |
68 | 68 |
69 | |
70 def get_session(): | 69 def get_session(): |
71 if CELERY_ON: | 70 if CELERY_ON: |
72 engine = engine_from_config(config, 'sqlalchemy.db1.') | 71 engine = engine_from_config(config, 'sqlalchemy.db1.') |
73 init_model(engine) | 72 init_model(engine) |
74 sa = meta.Session() | 73 sa = meta.Session() |
110 akc = lambda k: person(k).replace('"', "") | 109 akc = lambda k: person(k).replace('"', "") |
111 | 110 |
112 co_day_auth_aggr = {} | 111 co_day_auth_aggr = {} |
113 commits_by_day_aggregate = {} | 112 commits_by_day_aggregate = {} |
114 repos_path = get_repos_path() | 113 repos_path = get_repos_path() |
115 p = os.path.join(repos_path, repo_name) | 114 repo = get_repo(safe_str(os.path.join(repos_path, repo_name))) |
116 repo = get_repo(p) | |
117 repo_size = len(repo.revisions) | 115 repo_size = len(repo.revisions) |
118 #return if repo have no revisions | 116 #return if repo have no revisions |
119 if repo_size < 1: | 117 if repo_size < 1: |
120 lock.release() | 118 lock.release() |
121 return True | 119 return True |
356 backend(str(repo_fork_path), create=True, src_url=str(repo_path)) | 354 backend(str(repo_fork_path), create=True, src_url=str(repo_path)) |
357 | 355 |
358 | 356 |
359 def __get_codes_stats(repo_name): | 357 def __get_codes_stats(repo_name): |
360 repos_path = get_repos_path() | 358 repos_path = get_repos_path() |
361 p = os.path.join(repos_path, repo_name) | 359 repo = get_repo(safe_str(os.path.join(repos_path, repo_name))) |
362 repo = get_repo(p) | |
363 tip = repo.get_changeset() | 360 tip = repo.get_changeset() |
364 code_stats = {} | 361 code_stats = {} |
365 | 362 |
366 def aggregate(cs): | 363 def aggregate(cs): |
367 for f in cs[2]: | 364 for f in cs[2]: |