Changeset - f4a9f7a7d030
[Not reviewed]
default
0 1 0
Thomas De Schampheleire - 7 years ago 2018-11-22 22:27:14
thomas.de_schampheleire@nokia.com
cli: fix celery-run usage text

Make sure that the help text and error messages from Celery (e.g. from
'kallithea-cli celery-run -c my.ini -- --help' or '-- -xyz') contain a valid
'Usage:' string.

Without these changes, the usage string will use the arbitrary description from
2c3d30095d5e and a full path:
Usage: kallithea celery worker .../bin/kallithea-cli [options]

With the changes, it becomes:
Usage: kallithea-cli celery-run -c CONFIG_FILE -- [options]

Click will let optparse find 'kallithea-cli' from argv[0]. The command part
'celery-run -c CONFIG_FILE --' could perhaps be found with Click introspection,
but it is simpler and perhaps equally reliable to make it explicit.

Original change modified by Mads Kiilerich.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/bin/kallithea_cli_celery.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# This program is free software: you can redistribute it and/or modify
 
# it under the terms of the GNU General Public License as published by
 
# the Free Software Foundation, either version 3 of the License, or
 
# (at your option) any later version.
 
#
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 

	
 
import click
 
import kallithea.bin.kallithea_cli_base as cli_base
 

	
 
import kallithea
 

	
 
@cli_base.register_command(config_file_initialize_app=True)
 
@click.argument('celery_args', nargs=-1)
 
def celery_run(celery_args):
 
    """Start Celery worker(s) for asynchronous tasks.
 

	
 
    This commands starts the Celery daemon which will spawn workers to handle
 
    certain asynchronous tasks for Kallithea.
 

	
 
    Any extra arguments you pass to this command will be passed through to
 
    Celery. Use '--' before such extra arguments to avoid options to be parsed
 
    by this CLI command.
 
    """
 

	
 
    if not kallithea.CELERY_ON:
 
        raise Exception('Please set use_celery = true in .ini config '
 
                        'file before running this command')
 

	
 
    from kallithea.lib import celerypylons
 
    cmd = celerypylons.worker.worker(celerypylons.app)
 
    return cmd.run_from_argv('kallithea celery worker', list(celery_args))
 
    return cmd.run_from_argv(None, command='celery-run -c CONFIG_FILE --', argv=list(celery_args))
0 comments (0 inline, 0 general)