This document describes the current stable version of Celery (4.0). 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
Command.Parser

alias of ArgumentParser

exception Command.UsageError(reason, status=None)

Exception raised for malformed arguments.

status = 64
Command.add_append_opt(acc, opt, value)[source]
Command.add_arguments(parser)[source]
Command.add_compat_options(parser, options)[source]
Command.add_preload_arguments(parser)[source]
Command.args = u''
Command.args_name = u'args'
Command.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.
Command.check_args(args)[source]
Command.colored
Command.create_parser(prog_name, command=None)[source]
Command.description = u''
Command.die(msg, status=1)[source]
Command.doc = None
Command.early_version(argv)[source]
Command.enable_config_from_cmdline = False
Command.epilog = None
Command.error(s)[source]
Command.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.
Command.expanduser(value)[source]
Command.find_app(app)[source]
Command.get_cls_by_name(name, imp=<function import_from_cwd>)
Command.get_options()[source]
Command.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.
Command.host_format(s, **extra)[source]
Command.leaf = True
Command.maybe_patch_concurrency(argv=None)[source]
Command.namespace = None
Command.no_color
Command.node_format(s, nodename, **extra)[source]
Command.on_concurrency_setup()[source]
Command.on_error(exc)[source]
Command.on_usage_error(exc)[source]
Command.option_list = None
Command.out(s, fh=None)[source]
Command.parse_doc(doc)[source]
Command.parse_options(prog_name, arguments, command=None)[source]

Parse the available options.

Command.parse_preload_options(args)[source]
Command.prepare_args(options, args)[source]
Command.prepare_arguments(parser)[source]
Command.prepare_parser(parser)[source]
Command.pretty(n)[source]
Command.pretty_dict_ok_error(n)[source]
Command.pretty_list(n)[source]
Command.process_cmdline_config(argv)[source]
Command.prog_name = u'celery'
Command.respects_app_option = True
Command.run(*args, **options)[source]
Command.run_from_argv(prog_name, argv=None, command=None)[source]
Command.say_chat(direction, title, body=u'')[source]
Command.say_remote_command_reply(replies)[source]
Command.setup_app_from_commandline(argv)[source]
Command.show_body = True
Command.show_reply = True
Command.supports_args = True
Command.symbol_by_name(name, imp=<function import_from_cwd>)[source]
Command.usage(command)[source]
Command.verify_args(given, _index=0)[source]
Command.version = u'4.0.2 (latentcall)'
Command.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 = {'int': <function check_builtin>, 'float': <function check_builtin>, 'complex': <function check_builtin>, 'long': <function check_builtin>, 'choice': <function check_choice>}
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.