celery.bin.base

Preload Options

These options are supported by all commands, and usually parsed before command-specific arguments.

-A, --app

app instance to use (e.g. module.attr_name)

-b, --broker

url to broker. default is ‘amqp://guest@localhost//’

--loader

name of custom loader class to use.

--config

Name of the configuration module

Daemon Options

These options are supported by commands that can detach into the background (daemon). They will be present in any command that also has a –detach option.

-f, --logfile

Path to log file. If no logfile is specified, stderr is used.

--pidfile

Optional file used to store the process pid.

The program will not start if this file already exists and the pid is still alive.

--uid

User id, or user name of the user to run as after detaching.

--gid

Group id, or group name of the main group to change to after detaching.

--umask

Effective umask of the process after detaching. Default is 0.

--workdir

Optional directory to change to after detaching.

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

  • status = 1

exception celery.bin.base.UsageError(reason, status=None)

  • status = 64

class celery.bin.base.Extensions(namespace, register)

  • add(cls, name)

  • load()

class celery.bin.base.HelpFormatter(indent_increment=2, max_help_position=24, width=None, short_first=1)[源代码]

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)[源代码]

Base class for command-line applications.

参数:
  • app – The current app.
  • get_app – Callable returning the current app if no app provided.
  • exception Error(reason, status=None)

    • status = 1
  • Command.Parser

    OptionParser 的别名

  • exception Command.UsageError(reason, status=None)

    • status = 64
  • Command.args = u’’

  • Command.check_args(args)[源代码]

  • Command.create_parser(prog_name, command=None)[源代码]

  • Command.description = u’’

  • Command.die(msg, status=1)[源代码]

  • Command.doc = None

  • Command.early_version(argv)[源代码]

  • Command.enable_config_from_cmdline = False

  • Command.epilog = None

  • Command.error(s)

  • Command.execute_from_commandline(argv=None)[源代码]

    Execute application from command-line.

    参数:argv – The list of command-line arguments. Defaults to sys.argv.
  • Command.expanduser(value)[源代码]

  • Command.find_app(app)[源代码]

  • Command.get_cls_by_name(name, imp=<function import_from_cwd at 0xb08d87c>)

  • Command.get_options()[源代码]

    Get supported command-line options.

  • Command.handle_argv(prog_name, argv, command=None)[源代码]

    Parse command-line arguments from argv and dispatch to run().

    参数:
    • prog_name – The program name (argv[0]).
    • argv – Command arguments.

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

  • Command.leaf = True

  • Command.maybe_patch_concurrency(argv=None)[源代码]

  • Command.namespace = u’celery’

  • Command.node_format(s, nodename, \*extra*)

  • Command.on_concurrency_setup()[源代码]

  • Command.on_error(exc)

  • Command.on_usage_error(exc)

  • Command.option_list = ()

  • Command.out(s, fh=None)

  • Command.parse_doc(doc)[源代码]

  • Command.parse_options(prog_name, arguments, command=None)[源代码]

    Parse the available options.

  • Command.parse_preload_options(args)[源代码]

  • Command.preload_options = (<Option at 0xd0d4eec: -A/—app>, <Option at 0xd0d47cc: -b/—broker>, <Option at 0xd0d4e4c: —loader>, <Option at 0xd0d424c: —config>, <Option at 0xd0d42cc: —workdir>, <Option at 0xd09798c: -C/—no-color>, <Option at 0xd09754c: -q/—quiet>)

  • Command.prepare_args(options, args)[源代码]

  • Command.prepare_parser(parser)[源代码]

  • Command.preparse_options(args, options)

  • Command.pretty(n)

  • Command.pretty_dict_ok_error(n)

  • Command.pretty_list(n)

  • Command.process_cmdline_config(argv)[源代码]

  • Command.prog_name = u’celery’

  • Command.respects_app_option = True

  • Command.run(\args, **options*)[源代码]

    This is the body of the command called by handle_argv().

  • Command.run_from_argv(prog_name, argv=None, command=None)[源代码]

  • Command.say_chat(direction, title, body=u’’)

  • Command.say_remote_command_reply(replies)

  • Command.setup_app_from_commandline(argv)[源代码]

  • Command.show_body = True

  • Command.show_reply = True

  • Command.simple_format(s, \*extra*)

  • Command.supports_args = True

  • Command.symbol_by_name(name, imp=<function import_from_cwd at 0xb08d87c>)[源代码]

  • Command.usage(command)[源代码]

  • Command.verify_args(given, _index=0)

  • Command.version = ‘3.1.7 (Cipater)’

  • Command.with_pool_option(argv)[源代码]

    Return tuple of (short_opts, long_opts) if the command supports a pool argument, and used to monkey patch eventlet/gevent environments as early as possible.

    • E.g::

      has_pool_option = ([‘-P’], [‘–pool’])

class celery.bin.base.Option(\opts, **attrs*)

  • 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 at 0x91148ec>, <function _check_type at 0x9114924>, <function _check_choice at 0x911495c>, <function _check_dest at 0x9114994>, <function _check_const at 0x91149cc>, <function _check_nargs at 0x9114a04>, <function _check_callback at 0x9114a3c>]

  • 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 at 0x9114764>, ‘float’: <function check_builtin at 0x9114764>, ‘complex’: <function check_builtin at 0x9114764>, ‘long’: <function check_builtin at 0x9114764>, ‘choice’: <function check_choice at 0x911479c>}

  • check_value(opt, value)

  • convert_value(opt, value)

  • get_opt_string()

  • process(opt, value, values, parser)

  • take_action(action, dest, opt, value, values, parser)

  • takes_value()

celery.bin.base.daemon_options(default_pidfile=None, default_logfile=None)[源代码]