##// END OF EJS Templates
pylons: deprecate certain pylons paster command
marcink -
r2356:12ce62ea default
parent child Browse files
Show More
1 NO CONTENT: new file 100644
@@ -0,0 +1,43 b''
1 # -*- coding: utf-8 -*-
2
3 # Copyright (C) 2013-2017 RhodeCode GmbH
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
21
22 from rhodecode.lib.paster_commands import BasePasterCommand
23
24
25 class Command(BasePasterCommand):
26 """
27 Start the celery worker
28
29 Starts the celery worker that uses a paste.deploy configuration
30 file.
31 """
32 usage = 'CONFIG_FILE [celeryd options...]'
33 summary = __doc__.splitlines()[0]
34 description = "".join(__doc__.splitlines()[2:])
35
36 parser = BasePasterCommand.standard_parser(quiet=True)
37
38 def update_parser(self):
39 pass
40
41 def command(self):
42 cmd = 'celery worker --beat --app rhodecode.lib.celerylib.loader --loglevel DEBUG --ini=%s' % self.path_to_ini_file
43 raise Exception('This Command is deprecated please run: %s' % cmd) No newline at end of file
@@ -17,3 +17,74 b''
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 import os
21 import logging
22
23 from paste.script.command import Command, BadCommand
24
25
26 class BasePasterCommand(Command):
27 """
28 Abstract Base Class for paster commands.
29
30 The celery commands are somewhat aggressive about loading
31 celery.conf, and since our module sets the `CELERY_LOADER`
32 environment variable to our loader, we have to bootstrap a bit and
33 make sure we've had a chance to load the pylons config off of the
34 command line, otherwise everything fails.
35 """
36 min_args = 1
37 min_args_error = "Please provide a paster config file as an argument."
38 takes_config_file = 1
39 requires_config_file = True
40
41 def notify_msg(self, msg, log=False):
42 """Make a notification to user, additionally if logger is passed
43 it logs this action using given logger
44
45 :param msg: message that will be printed to user
46 :param log: logging instance, to use to additionally log this message
47
48 """
49 if log and isinstance(log, logging):
50 log(msg)
51
52 def run(self, args):
53 """
54 Overrides Command.run
55
56 Checks for a config file argument and loads it.
57 """
58 if len(args) < self.min_args:
59 raise BadCommand(
60 self.min_args_error % {'min_args': self.min_args,
61 'actual_args': len(args)})
62
63 # Decrement because we're going to lob off the first argument.
64 # @@ This is hacky
65 self.min_args -= 1
66 self.bootstrap_config(args[0])
67 self.update_parser()
68 return super(BasePasterCommand, self).run(args[1:])
69
70 def update_parser(self):
71 """
72 Abstract method. Allows for the class' parser to be updated
73 before the superclass' `run` method is called. Necessary to
74 allow options/arguments to be passed through to the underlying
75 celery command.
76 """
77 raise NotImplementedError("Abstract Method.")
78
79 def bootstrap_config(self, conf):
80 """
81 Loads the pylons configuration.
82 """
83 self.path_to_ini_file = os.path.realpath(conf)
84
85 def _init_session(self):
86 """
87 Inits SqlAlchemy Session
88 """
89 logging.config.fileConfig(self.path_to_ini_file)
90
@@ -25,14 +25,13 b' deprecated make-config paster command fo'
25 25 import os
26 26 import sys
27 27 from paste.script.appinstall import AbstractInstallCommand
28 from paste.script.command import BadCommand
29 from paste.deploy import appconfig
30 28
31 29 # fix rhodecode import
32 30 from os.path import dirname as dn
33 31 rc_path = dn(dn(dn(os.path.realpath(__file__))))
34 32 sys.path.append(rc_path)
35 33
34
36 35 class Command(AbstractInstallCommand):
37 36
38 37 default_verbosity = 1
@@ -26,7 +26,7 b' import os'
26 26 import sys
27 27 import logging
28 28
29 from rhodecode.lib.utils import BasePasterCommand
29 from rhodecode.lib.paster_commands import BasePasterCommand
30 30
31 31 # fix rhodecode import
32 32 from os.path import dirname as dn
@@ -155,11 +155,12 b' setup('
155 155 'main=rhodecode.config.middleware:make_pyramid_app',
156 156 ],
157 157 'paste.global_paster_command': [
158 'make-config=rhodecode.lib.paster_commands.make_config:Command',
159 158 'setup-rhodecode=rhodecode.lib.paster_commands.setup_rhodecode:Command',
160 159 'ishell=rhodecode.lib.paster_commands.ishell:Command',
161 160 'upgrade-db=rhodecode.lib.dbmigrate:UpgradeDb',
162 'celeryd=rhodecode.lib.celerypylons.commands:CeleryDaemonCommand',
161
162 'make-config=rhodecode.lib.paster_commands.make_config:Command',
163 'celeryd=rhodecode.lib.paster_commands.deprecated.celeryd:Command',
163 164 ],
164 165 'pyramid.pshell_runner': [
165 166 'ipython = rhodecode.lib.pyramid_shell:ipython_shell_runner',
General Comments 0
You need to be logged in to leave comments. Login now