##// END OF EJS Templates
celery: upgrade to Celery 3...
Mads Kiilerich -
r6137:4f2e231d default
parent child Browse files
Show More
@@ -1,36 +1,36 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 """
3 """
4 Kallithea wrapper of Celery
4 Kallithea wrapper of Celery
5
5
6 The Celery configuration is in the normal Pylons ini file. We thus have to set
6 The Celery configuration is in the normal Pylons ini file. We thus have to set
7 the `CELERY_LOADER` environment variable to point at a custom "loader" that can
7 the `CELERY_LOADER` environment variable to point at a custom "loader" that can
8 read it. That environment variable must be set *before* importing celery. To
8 read it. That environment variable must be set *before* importing celery. To
9 ensure that, we wrap celery in this module.
9 ensure that, we wrap celery in this module.
10
10
11 Also, the loader depends on Pylons being configured to it can read the Celery
11 Also, the loader depends on Pylons being configured to it can read the Celery
12 configuration out of it. To make sure that really is the case and give an early
12 configuration out of it. To make sure that really is the case and give an early
13 warning, we check one of the mandatory settings.
13 warning, we check one of the mandatory settings.
14
14
15 This module must thus not be imported in global scope but must be imported on
15 This module must thus not be imported in global scope but must be imported on
16 demand in function scope.
16 demand in function scope.
17 """
17 """
18
18
19 import os
19 import os
20 import warnings
20 import warnings
21
21
22 # Verify Pylons configuration has been loaded
22 # Verify Pylons configuration has been loaded
23 from pylons import config
23 from pylons import config
24 assert config['celery.imports'] == 'kallithea.lib.celerylib.tasks', 'Kallithea Celery configuration has not been loaded'
24 assert config['celery.imports'] == 'kallithea.lib.celerylib.tasks', 'Kallithea Celery configuration has not been loaded'
25
25
26 # Prepare environment to point at Kallithea Pylons loader
26 # Prepare environment to point at Kallithea Pylons loader
27 CELERYPYLONS_LOADER = 'kallithea.lib.celerypylons.loader.PylonsLoader'
27 CELERYPYLONS_LOADER = 'kallithea.lib.celerypylons.loader.PylonsLoader'
28 if os.environ.get('CELERY_LOADER', CELERYPYLONS_LOADER) != CELERYPYLONS_LOADER:
28 if os.environ.get('CELERY_LOADER', CELERYPYLONS_LOADER) != CELERYPYLONS_LOADER:
29 warnings.warn("'CELERY_LOADER' environment variable will be overridden by celery-pylons.")
29 warnings.warn("'CELERY_LOADER' environment variable will be overridden by celery-pylons.")
30 os.environ['CELERY_LOADER'] = CELERYPYLONS_LOADER
30 os.environ['CELERY_LOADER'] = CELERYPYLONS_LOADER
31
31
32 # Import (and expose) celery, thus immediately triggering use of the custom Pylons loader
32 # Import (and expose) celery, thus immediately triggering use of the custom Pylons loader
33 import celery.app as app
33 import celery.app as app
34 import celery.result as result
34 import celery.result as result
35 from celery.task import task
35 from celery.task import task
36 from celery.bin import celeryd
36 from celery.bin import worker
@@ -1,46 +1,46 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 import kallithea
3 import kallithea
4 from kallithea.lib.paster_commands.common import BasePasterCommand
4 from kallithea.lib.paster_commands.common import BasePasterCommand
5 from kallithea.lib.utils import load_rcextensions
5 from kallithea.lib.utils import load_rcextensions
6 from kallithea.lib.utils2 import str2bool
6 from kallithea.lib.utils2 import str2bool
7
7
8 __all__ = ['Command']
8 __all__ = ['Command']
9
9
10
10
11 class Command(BasePasterCommand):
11 class Command(BasePasterCommand):
12 """Start the celery worker
12 """Start the celery worker
13
13
14 Starts the celery worker that uses a paste.deploy configuration
14 Starts the celery worker that uses a paste.deploy configuration
15 file.
15 file.
16 """
16 """
17
17
18 usage = 'CONFIG_FILE [celeryd options...]'
18 usage = 'CONFIG_FILE [celeryd options...]'
19 summary = __doc__.splitlines()[0]
19 summary = __doc__.splitlines()[0]
20 description = "".join(__doc__.splitlines()[2:])
20 description = "".join(__doc__.splitlines()[2:])
21 group_name = "Kallithea"
21 group_name = "Kallithea"
22
22
23 parser = BasePasterCommand.standard_parser(quiet=True)
23 parser = BasePasterCommand.standard_parser(quiet=True)
24
24
25 def update_parser(self):
25 def update_parser(self):
26 from kallithea.lib import celerypylons
26 from kallithea.lib import celerypylons
27 cmd = celerypylons.celeryd.WorkerCommand(celerypylons.app.app_or_default())
27 cmd = celerypylons.worker.worker(celerypylons.app.app_or_default())
28 for x in cmd.get_options():
28 for x in cmd.get_options():
29 self.parser.add_option(x)
29 self.parser.add_option(x)
30
30
31 def command(self):
31 def command(self):
32 from kallithea.lib import celerypylons
32 from kallithea.lib import celerypylons
33 from pylons import config
33 from pylons import config
34 try:
34 try:
35 CELERY_ON = str2bool(config['app_conf'].get('use_celery'))
35 CELERY_ON = str2bool(config['app_conf'].get('use_celery'))
36 except KeyError:
36 except KeyError:
37 CELERY_ON = False
37 CELERY_ON = False
38
38
39 if not CELERY_ON:
39 if not CELERY_ON:
40 raise Exception('Please set use_celery = true in .ini config '
40 raise Exception('Please set use_celery = true in .ini config '
41 'file before running celeryd')
41 'file before running celeryd')
42 kallithea.CELERY_ON = CELERY_ON
42 kallithea.CELERY_ON = CELERY_ON
43
43
44 load_rcextensions(config['here'])
44 load_rcextensions(config['here'])
45 cmd = celerypylons.celeryd.WorkerCommand(celerypylons.app.app_or_default())
45 cmd = celerypylons.worker.worker(celerypylons.app.app_or_default())
46 return cmd.run(**vars(self.options))
46 return cmd.run(**vars(self.options))
@@ -1,172 +1,172 b''
1 #!/usr/bin/env python2
1 #!/usr/bin/env python2
2 # -*- coding: utf-8 -*-
2 # -*- coding: utf-8 -*-
3 import os
3 import os
4 import sys
4 import sys
5 import platform
5 import platform
6
6
7 if sys.version_info < (2, 6) or sys.version_info >= (3,):
7 if sys.version_info < (2, 6) or sys.version_info >= (3,):
8 raise Exception('Kallithea requires python 2.6 or 2.7')
8 raise Exception('Kallithea requires python 2.6 or 2.7')
9
9
10
10
11 here = os.path.abspath(os.path.dirname(__file__))
11 here = os.path.abspath(os.path.dirname(__file__))
12
12
13
13
14 def _get_meta_var(name, data, callback_handler=None):
14 def _get_meta_var(name, data, callback_handler=None):
15 import re
15 import re
16 matches = re.compile(r'(?:%s)\s*=\s*(.*)' % name).search(data)
16 matches = re.compile(r'(?:%s)\s*=\s*(.*)' % name).search(data)
17 if matches:
17 if matches:
18 if not callable(callback_handler):
18 if not callable(callback_handler):
19 callback_handler = lambda v: v
19 callback_handler = lambda v: v
20
20
21 return callback_handler(eval(matches.groups()[0]))
21 return callback_handler(eval(matches.groups()[0]))
22
22
23 _meta = open(os.path.join(here, 'kallithea', '__init__.py'), 'rb')
23 _meta = open(os.path.join(here, 'kallithea', '__init__.py'), 'rb')
24 _metadata = _meta.read()
24 _metadata = _meta.read()
25 _meta.close()
25 _meta.close()
26
26
27 callback = lambda V: ('.'.join(map(str, V[:3])) + '.'.join(V[3:]))
27 callback = lambda V: ('.'.join(map(str, V[:3])) + '.'.join(V[3:]))
28 __version__ = _get_meta_var('VERSION', _metadata, callback)
28 __version__ = _get_meta_var('VERSION', _metadata, callback)
29 __license__ = _get_meta_var('__license__', _metadata)
29 __license__ = _get_meta_var('__license__', _metadata)
30 __author__ = _get_meta_var('__author__', _metadata)
30 __author__ = _get_meta_var('__author__', _metadata)
31 __url__ = _get_meta_var('__url__', _metadata)
31 __url__ = _get_meta_var('__url__', _metadata)
32 # defines current platform
32 # defines current platform
33 __platform__ = platform.system()
33 __platform__ = platform.system()
34
34
35 is_windows = __platform__ in ['Windows']
35 is_windows = __platform__ in ['Windows']
36
36
37 requirements = [
37 requirements = [
38 "alembic>=0.8.0,<0.9",
38 "alembic>=0.8.0,<0.9",
39 "waitress>=0.8.8,<1.0",
39 "waitress>=0.8.8,<1.0",
40 "webob>=1.0.8,<=1.1.1",
40 "webob>=1.0.8,<=1.1.1",
41 "Pylons>=1.0.0,<=1.0.2",
41 "Pylons>=1.0.0,<=1.0.2",
42 "WebTest<2.0", # make the Pylons dependency pick a version that supports our WebOb version
42 "WebTest<2.0", # make the Pylons dependency pick a version that supports our WebOb version
43 "Beaker==1.6.4",
43 "Beaker==1.6.4",
44 "WebHelpers==1.3",
44 "WebHelpers==1.3",
45 "formencode>=1.2.4,<=1.2.6",
45 "formencode>=1.2.4,<=1.2.6",
46 "SQLAlchemy>=1.0,<1.1",
46 "SQLAlchemy>=1.0,<1.1",
47 "Mako>=0.9.0,<=1.0.0",
47 "Mako>=0.9.0,<=1.0.0",
48 "pygments>=1.5",
48 "pygments>=1.5",
49 "whoosh>=2.4.0,<=2.5.7",
49 "whoosh>=2.4.0,<=2.5.7",
50 "celery>=2.2.5,<2.3",
50 "celery>=3.1,<3.2",
51 "babel>=0.9.6,<=1.3",
51 "babel>=0.9.6,<=1.3",
52 "python-dateutil>=1.5.0,<2.0.0",
52 "python-dateutil>=1.5.0,<2.0.0",
53 "markdown==2.2.1",
53 "markdown==2.2.1",
54 "docutils>=0.8.1,<=0.11",
54 "docutils>=0.8.1,<=0.11",
55 "URLObject==2.3.4",
55 "URLObject==2.3.4",
56 "Routes==1.13",
56 "Routes==1.13",
57 "dulwich>=0.14.1",
57 "dulwich>=0.14.1",
58 "mercurial>=2.9,<4.0",
58 "mercurial>=2.9,<4.0",
59 ]
59 ]
60
60
61 if sys.version_info < (2, 7):
61 if sys.version_info < (2, 7):
62 requirements.append("importlib==1.0.1")
62 requirements.append("importlib==1.0.1")
63 requirements.append("argparse")
63 requirements.append("argparse")
64
64
65 if not is_windows:
65 if not is_windows:
66 requirements.append("bcrypt>=2.0.0")
66 requirements.append("bcrypt>=2.0.0")
67
67
68 dependency_links = [
68 dependency_links = [
69 ]
69 ]
70
70
71 classifiers = [
71 classifiers = [
72 'Development Status :: 4 - Beta',
72 'Development Status :: 4 - Beta',
73 'Environment :: Web Environment',
73 'Environment :: Web Environment',
74 'Framework :: Pylons',
74 'Framework :: Pylons',
75 'Intended Audience :: Developers',
75 'Intended Audience :: Developers',
76 'License :: OSI Approved :: GNU General Public License (GPL)',
76 'License :: OSI Approved :: GNU General Public License (GPL)',
77 'Operating System :: OS Independent',
77 'Operating System :: OS Independent',
78 'Programming Language :: Python',
78 'Programming Language :: Python',
79 'Programming Language :: Python :: 2.6',
79 'Programming Language :: Python :: 2.6',
80 'Programming Language :: Python :: 2.7',
80 'Programming Language :: Python :: 2.7',
81 'Topic :: Software Development :: Version Control',
81 'Topic :: Software Development :: Version Control',
82 ]
82 ]
83
83
84
84
85 # additional files from project that goes somewhere in the filesystem
85 # additional files from project that goes somewhere in the filesystem
86 # relative to sys.prefix
86 # relative to sys.prefix
87 data_files = []
87 data_files = []
88
88
89 description = ('Kallithea is a fast and powerful management tool '
89 description = ('Kallithea is a fast and powerful management tool '
90 'for Mercurial and Git with a built in push/pull server, '
90 'for Mercurial and Git with a built in push/pull server, '
91 'full text search and code-review.')
91 'full text search and code-review.')
92
92
93 keywords = ' '.join([
93 keywords = ' '.join([
94 'kallithea', 'mercurial', 'git', 'code review',
94 'kallithea', 'mercurial', 'git', 'code review',
95 'repo groups', 'ldap', 'repository management', 'hgweb replacement',
95 'repo groups', 'ldap', 'repository management', 'hgweb replacement',
96 'hgwebdir', 'gitweb replacement', 'serving hgweb',
96 'hgwebdir', 'gitweb replacement', 'serving hgweb',
97 ])
97 ])
98
98
99 # long description
99 # long description
100 README_FILE = 'README.rst'
100 README_FILE = 'README.rst'
101 try:
101 try:
102 long_description = open(README_FILE).read()
102 long_description = open(README_FILE).read()
103 except IOError as err:
103 except IOError as err:
104 sys.stderr.write(
104 sys.stderr.write(
105 "[WARNING] Cannot find file specified as long_description (%s)\n"
105 "[WARNING] Cannot find file specified as long_description (%s)\n"
106 % README_FILE
106 % README_FILE
107 )
107 )
108 long_description = description
108 long_description = description
109
109
110 import setuptools
110 import setuptools
111
111
112 # monkey patch setuptools to use distutils owner/group functionality
112 # monkey patch setuptools to use distutils owner/group functionality
113 from setuptools.command import sdist
113 from setuptools.command import sdist
114 sdist_org = sdist.sdist
114 sdist_org = sdist.sdist
115 class sdist_new(sdist_org):
115 class sdist_new(sdist_org):
116 def initialize_options(self):
116 def initialize_options(self):
117 sdist_org.initialize_options(self)
117 sdist_org.initialize_options(self)
118 self.owner = self.group = 'root'
118 self.owner = self.group = 'root'
119 sdist.sdist = sdist_new
119 sdist.sdist = sdist_new
120
120
121 packages = setuptools.find_packages(exclude=['ez_setup'])
121 packages = setuptools.find_packages(exclude=['ez_setup'])
122
122
123 setuptools.setup(
123 setuptools.setup(
124 name='Kallithea',
124 name='Kallithea',
125 version=__version__,
125 version=__version__,
126 description=description,
126 description=description,
127 long_description=long_description,
127 long_description=long_description,
128 keywords=keywords,
128 keywords=keywords,
129 license=__license__,
129 license=__license__,
130 author=__author__,
130 author=__author__,
131 author_email='kallithea@sfconservancy.org',
131 author_email='kallithea@sfconservancy.org',
132 dependency_links=dependency_links,
132 dependency_links=dependency_links,
133 url=__url__,
133 url=__url__,
134 install_requires=requirements,
134 install_requires=requirements,
135 classifiers=classifiers,
135 classifiers=classifiers,
136 setup_requires=['PasteScript>=1.6.3'],
136 setup_requires=['PasteScript>=1.6.3'],
137 data_files=data_files,
137 data_files=data_files,
138 packages=packages,
138 packages=packages,
139 include_package_data=True,
139 include_package_data=True,
140 message_extractors={'kallithea': [
140 message_extractors={'kallithea': [
141 ('**.py', 'python', None),
141 ('**.py', 'python', None),
142 ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
142 ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
143 ('templates/**.html', 'mako', {'input_encoding': 'utf-8'}),
143 ('templates/**.html', 'mako', {'input_encoding': 'utf-8'}),
144 ('public/**', 'ignore', None)]},
144 ('public/**', 'ignore', None)]},
145 zip_safe=False,
145 zip_safe=False,
146 paster_plugins=['PasteScript', 'Pylons'],
146 paster_plugins=['PasteScript', 'Pylons'],
147 entry_points="""
147 entry_points="""
148 [console_scripts]
148 [console_scripts]
149 kallithea-api = kallithea.bin.kallithea_api:main
149 kallithea-api = kallithea.bin.kallithea_api:main
150 kallithea-gist = kallithea.bin.kallithea_gist:main
150 kallithea-gist = kallithea.bin.kallithea_gist:main
151 kallithea-config = kallithea.bin.kallithea_config:main
151 kallithea-config = kallithea.bin.kallithea_config:main
152
152
153 [paste.app_factory]
153 [paste.app_factory]
154 main = kallithea.config.middleware:make_app
154 main = kallithea.config.middleware:make_app
155
155
156 [paste.app_install]
156 [paste.app_install]
157 main = pylons.util:PylonsInstaller
157 main = pylons.util:PylonsInstaller
158
158
159 [paste.global_paster_command]
159 [paste.global_paster_command]
160 setup-db=kallithea.lib.paster_commands.setup_db:Command
160 setup-db=kallithea.lib.paster_commands.setup_db:Command
161 cleanup-repos=kallithea.lib.paster_commands.cleanup:Command
161 cleanup-repos=kallithea.lib.paster_commands.cleanup:Command
162 update-repoinfo=kallithea.lib.paster_commands.update_repoinfo:Command
162 update-repoinfo=kallithea.lib.paster_commands.update_repoinfo:Command
163 make-rcext=kallithea.lib.paster_commands.make_rcextensions:Command
163 make-rcext=kallithea.lib.paster_commands.make_rcextensions:Command
164 repo-scan=kallithea.lib.paster_commands.repo_scan:Command
164 repo-scan=kallithea.lib.paster_commands.repo_scan:Command
165 cache-keys=kallithea.lib.paster_commands.cache_keys:Command
165 cache-keys=kallithea.lib.paster_commands.cache_keys:Command
166 ishell=kallithea.lib.paster_commands.ishell:Command
166 ishell=kallithea.lib.paster_commands.ishell:Command
167 make-index=kallithea.lib.paster_commands.make_index:Command
167 make-index=kallithea.lib.paster_commands.make_index:Command
168 upgrade-db=kallithea.lib.dbmigrate:UpgradeDb
168 upgrade-db=kallithea.lib.dbmigrate:UpgradeDb
169 celeryd=kallithea.lib.paster_commands.celeryd:Command
169 celeryd=kallithea.lib.paster_commands.celeryd:Command
170 install-iis=kallithea.lib.paster_commands.install_iis:Command
170 install-iis=kallithea.lib.paster_commands.install_iis:Command
171 """,
171 """,
172 )
172 )
General Comments 0
You need to be logged in to leave comments. Login now