This document describes the current stable version of Celery (4.2). For development docs, go here.

celery.bin.base

Base command-line interface.

exception celery.bin.base.Error(reason, status=None)[source]

Exception raised by commands.

status = 1
exception celery.bin.base.UsageError(reason, status=None)[source]

Exception raised for malformed arguments.

status = 64
class celery.bin.base.Extensions(namespace, register)[source]

Loads extensions from setuptools entrypoints.

add(cls, name)[source]
load()[source]
class celery.bin.base.Command(app=None, get_app=None, no_color=False, stdout=None, stderr=None, quiet=False, on_error=None, on_usage_error=None)[source]

Base class for command-line applications.

Parameters:
  • app (Celery) – The app to use.
  • get_app (Callable) – Fucntion returning the current app when no app provided.
exception Error(reason, status=None)

Exception raised by commands.

status = 1
Parser

alias of argparse.ArgumentParser

exception UsageError(reason, status=None)

Exception raised for malformed arguments.

status = 64
add_append_opt(acc, opt, value)[source]
add_arguments(parser)[source]
add_compat_options(parser, options)[source]
add_preload_arguments(parser)[source]
args = u''

Arg list used in help.

args_name = u'args'

Name of argparse option used for parsing positional args.

ask(q, choices, default=None)[source]

Prompt user to choose from a tuple of string values.

If a default is not specified the question will be repeated until the user gives a valid choice.

Matching is case insensitive.

Parameters:
  • q (str) – the question to ask (don’t include questionark)
  • choice (Tuple[str]) – tuple of possible choices, must be lowercase.
  • default (Any) – Default value if any.
check_args(args)[source]
colored
create_parser(prog_name, command=None)[source]
description = u''

Text to print in –help before option list.

die(msg, status=1)[source]
doc = None
early_version(argv)[source]
enable_config_from_cmdline = False

Enable if the application should support config from the cmdline.

epilog = None

Text to print at end of –help

error(s)[source]
execute_from_commandline(argv=None)[source]

Execute application from command-line.

Parameters:argv (List[str]) – The list of command-line arguments. Defaults to sys.argv.
expanduser(value)[source]
find_app(app)[source]
get_cls_by_name(name, imp=<function import_from_cwd>)
get_options()[source]
handle_argv(prog_name, argv, command=None)[source]

Parse arguments from argv and dispatch to run().

Warning

Exits with an error message if supports_args is disabled and argv contains positional arguments.

Parameters:
  • prog_name (str) – The program name (argv[0]).
  • argv (List[str]) – Rest of command-line arguments.
host_format(s, **extra)[source]
leaf = True

Set to true if this command doesn’t have sub-commands

maybe_patch_concurrency(argv=None)[source]
namespace = None

Default configuration name-space.

no_color
node_format(s, nodename, **extra)[source]
on_concurrency_setup()[source]
on_error(exc)[source]
on_usage_error(exc)[source]
option_list = None

List of options (without preload options).

out(s, fh=None)[source]
parse_doc(doc)[source]
parse_options(prog_name, arguments, command=None)[source]

Parse the available options.

parse_preload_options(args)[source]
prepare_args(options, args)[source]
prepare_arguments(parser)[source]
prepare_parser(parser)[source]
pretty(n)[source]
pretty_dict_ok_error(n)[source]
pretty_list(n)[source]
process_cmdline_config(argv)[source]
prog_name = u'celery'
respects_app_option = True
run(*args, **options)[source]
run_from_argv(prog_name, argv=None, command=None)[source]
say_chat(direction, title, body=u'')[source]
say_remote_command_reply(replies)[source]
setup_app_from_commandline(argv)[source]
show_body = True
show_reply = True
supports_args = True

If false the parser will raise an exception if positional args are provided.

symbol_by_name(name, imp=<function import_from_cwd>)[source]
usage(command)[source]
verify_args(given, _index=0)[source]
version = u'4.2.2 (windowlicker)'

Application version.

with_pool_option(argv)[source]

Return tuple of (short_opts, long_opts).

Returns only if the command supports a pool argument, and used to monkey patch eventlet/gevent environments as early as possible.

Example

>>> has_pool_option = (['-P'], ['--pool'])
class celery.bin.base.Option(*opts, **attrs)[source]
Instance attributes:

_short_opts : [string] _long_opts : [string]

action : string type : string dest : string default : any nargs : int const : any choices : [string] callback : function callback_args : (any*) callback_kwargs : { string : any } help : string metavar : string

ACTIONS = ('store', 'store_const', 'store_true', 'store_false', 'append', 'append_const', 'count', 'callback', 'help', 'version')
ALWAYS_TYPED_ACTIONS = ('store', 'append')
ATTRS = ['action', 'type', 'dest', 'default', 'nargs', 'const', 'choices', 'callback', 'callback_args', 'callback_kwargs', 'help', 'metavar']
CHECK_METHODS = [<function _check_action>, <function _check_type>, <function _check_choice>, <function _check_dest>, <function _check_const>, <function _check_nargs>, <function _check_callback>]
CONST_ACTIONS = ('store_const', 'append_const')
STORE_ACTIONS = ('store', 'store_const', 'store_true', 'store_false', 'append', 'append_const', 'count')
TYPED_ACTIONS = ('store', 'append', 'callback')
TYPES = ('string', 'int', 'long', 'float', 'complex', 'choice')
TYPE_CHECKER = {'choice': <function check_choice at 0x7f6de269f398>, 'complex': <function check_builtin at 0x7f6de269f320>, 'float': <function check_builtin at 0x7f6de269f320>, 'int': <function check_builtin at 0x7f6de269f320>, 'long': <function check_builtin at 0x7f6de269f320>}
check_value(opt, value)[source]
convert_value(opt, value)[source]
get_opt_string()[source]
process(opt, value, values, parser)[source]
take_action(action, dest, opt, value, values, parser)[source]
takes_value()[source]
celery.bin.base.daemon_options(parser, default_pidfile=None, default_logfile=None)[source]

Add daemon options to argparse parser.