• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python app.add_option函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twitter.common.app.add_option函数的典型用法代码示例。如果您正苦于以下问题:Python add_option函数的具体用法?Python add_option怎么用?Python add_option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了add_option函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: run

def run():
    def main(args, opts):
        """Main"""
        server = RedirServer(opts.zk_basepath,
                             opts.subdomain,
                             opts.base_domain)
        thread = ExceptionalThread(
            target=lambda: server.run(opts.listen,
                                      opts.port,
                                      server='cherrypy'))
        thread.daemon = True
        thread.start()

        wait_forever()

    log.LogOptions.set_stderr_log_level('google:INFO')

    app.add_option('--port', help='http port', default=8080)
    app.add_option('--listen',
                   help='IP address to listen for http connections.',
                   default='0.0.0.0')
    app.add_option('--zk_basepath',
                   help='Zookeeper service path root.',
                   default='/aurora')
    app.add_option('--base_domain',
                   help='Domain name of your site.',
                   default='example.com')
    app.add_option('--subdomain',
                   help='Subdomain that roots Aurora job namespace.',
                   default='aurora')

    app.main()
开发者ID:thinker0,项目名称:aurora-jobhopper,代码行数:32,代码来源:__main__.py


示例2: test_app_add_options_with_Option

 def test_app_add_options_with_Option(self):
   # options.Option
   opt = options.Option('--option1', dest='option1')
   app.add_option(opt)
   app.init(force_args=['--option1', 'option1value', 'extraargs'])
   assert app.get_options().option1 == 'option1value'
   assert app.argv() == ['extraargs']
开发者ID:billwei,项目名称:commons,代码行数:7,代码来源:test_app.py


示例3: add_verbosity_options

def add_verbosity_options():
    from twitter.common import app
    from twitter.common.log.options import LogOptions

    def set_quiet(option, _1, _2, parser):
        setattr(parser.values, option.dest, "quiet")
        LogOptions.set_stderr_log_level("NONE")

    def set_verbose(option, _1, _2, parser):
        setattr(parser.values, option.dest, "verbose")
        LogOptions.set_stderr_log_level("DEBUG")

    app.add_option(
        "-v",
        dest="verbosity",
        default="normal",
        action="callback",
        callback=set_verbose,
        help="Verbose logging. (default: %default)",
    )

    app.add_option(
        "-q",
        dest="verbosity",
        default="normal",
        action="callback",
        callback=set_quiet,
        help="Quiet logging. (default: %default)",
    )
开发者ID:retrack,项目名称:incubator-aurora,代码行数:29,代码来源:options.py


示例4: add_verbosity_options

def add_verbosity_options():
  from twitter.common import app
  from twitter.common.log.options import LogOptions

  def set_quiet(option, _1, _2, parser):
    setattr(parser.values, option.dest, 'quiet')
    LogOptions.set_stderr_log_level('NONE')

  def set_verbose(option, _1, _2, parser):
    setattr(parser.values, option.dest, 'verbose')
    LogOptions.set_stderr_log_level('DEBUG')

  app.add_option('-v',
                 dest='verbosity',
                 default='normal',
                 action='callback',
                 callback=set_verbose,
                 help='Verbose logging. (default: %default)')

  app.add_option('-q',
                 dest='verbosity',
                 default='normal',
                 action='callback',
                 callback=set_quiet,
                 help='Quiet logging. (default: %default)')
开发者ID:Empia,项目名称:incubator-aurora,代码行数:25,代码来源:options.py


示例5: setup

def setup():
  LogOptions.set_stderr_log_level('NONE')

  app.add_option('--iface', default='eth0', type=str)
  app.add_option('--port', default=3888, type=int)
  app.add_option('-c', '--colors', default=False, action='store_true')
  app.add_option('--dump-bad-packet', default=False, action='store_true')
  app.add_option('--version', default=False, action='store_true')
开发者ID:AkihiroSuda,项目名称:zktraffic,代码行数:8,代码来源:fle.py


示例6:

from apache.aurora.executor.aurora_executor import AuroraExecutor
from apache.aurora.executor.common.announcer import DefaultAnnouncerCheckerProvider
from apache.aurora.executor.common.executor_timeout import ExecutorTimeout
from apache.aurora.executor.common.health_checker import HealthCheckerProvider
from apache.aurora.executor.thermos_task_runner import DefaultThermosTaskRunnerProvider

app.configure(debug=True)
LogOptions.set_simple(True)
LogOptions.set_disk_log_level('DEBUG')
LogOptions.set_log_dir('.')


app.add_option(
    '--announcer-enable',
    dest='announcer_enable',
    action='store_true',
    default=False,
    help='Enable the ServerSet announcer for this executor.  Jobs must still activate using '
         'the Announcer configuration.')


app.add_option(
    '--announcer-ensemble',
    dest='announcer_ensemble',
    type=str,
    default=None,
    help='The ensemble to which the Announcer should register ServerSets.')


app.add_option(
    '--announcer-serverset-path',
开发者ID:aalzabarah,项目名称:incubator-aurora,代码行数:31,代码来源:thermos_executor_main.py


示例7: set_keep

from apache.thermos.common.ckpt import CheckpointDispatcher
from apache.thermos.common.constants import DEFAULT_CHECKPOINT_ROOT
from apache.thermos.common.options import add_binding_to, add_port_to
from apache.thermos.common.path import TaskPath
from apache.thermos.config.loader import ThermosConfigLoader, ThermosTaskWrapper
from apache.thermos.config.schema import Process, Resources, Task
from apache.thermos.core.helper import TaskRunnerHelper
from apache.thermos.core.runner import TaskRunner
from apache.thermos.monitoring.detector import TaskDetector
from apache.thermos.monitoring.garbage import DefaultCollector, TaskGarbageCollector
from apache.thermos.monitoring.monitor import TaskMonitor

from gen.apache.thermos.ttypes import ProcessState, RunnerCkpt, RunnerState, TaskState

app.add_option("--root", dest="root", metavar="PATH",
               default=DEFAULT_CHECKPOINT_ROOT,
               help="the thermos config root")


def set_keep(option, opt_str, value, parser):
  setattr(parser.values, option.dest, opt_str.startswith('--keep'))


def get_task_from_options(args, opts, **kw):
  loader = ThermosConfigLoader.load_json if opts.json else ThermosConfigLoader.load

  if len(args) != 1:
    app.error('Should specify precisely one config, instead got: %s' % args)

  tasks = loader(args[0], bindings=opts.bindings, **kw)
开发者ID:dominichamon,项目名称:incubator-aurora,代码行数:30,代码来源:thermos.py


示例8: timeout

# ==================================================================================================


import socket
import threading
import zookeeper
from functools import wraps
from twitter.common import app
from twitter.common import log
from twitter.common.log.options import LogOptions
from twitter.common.quantity import Amount, Time


app.add_option(
    '--zookeeper',
    default='zookeeper.local.twitter.com:2181',
    metavar='HOST:PORT[,HOST:PORT,...]',
    help='Comma-separated list of host:port of ZooKeeper servers',
    )
app.add_option(
    '--zookeeper_timeout',
    type='float',
    default=5.0,
    help='default timeout (in seconds) for ZK operations',
    )
app.add_option(
    '--enable_zookeeper_debug_logging',
    dest='twitter_common_zookeeper_debug',
    default=False,
    action='store_true',
    help='whether to enable ZK debug logging to stderr',
    )
开发者ID:adamsxu,项目名称:commons,代码行数:32,代码来源:client.py


示例9:


CWD = os.environ.get('MESOS_SANDBOX', '.')

app.configure(debug=True)
LogOptions.set_simple(True)
LogOptions.set_disk_log_level('DEBUG')
LogOptions.set_log_dir(CWD)

_LOGGER_TYPES = ', '.join(LoggerMode.VALUES)


app.add_option(
    '--announcer-enable',
    dest='announcer_enable',
    action='store_true',
    default=False,
    help='Enable the ServerSet announcer for this executor.  Jobs must still activate using '
         'the Announcer configuration.')


app.add_option(
    '--announcer-ensemble',
    dest='announcer_ensemble',
    type=str,
    default=None,
    help='The ensemble to which the Announcer should register ServerSets.')


app.add_option(
    '--announcer-serverset-path',
开发者ID:waterytowers,项目名称:aurora,代码行数:29,代码来源:thermos_executor_main.py


示例10:

import functools
import os
import signal
import sys
import traceback

from twitter.common import app, log
from apache.thermos.common.options import add_port_to
from apache.thermos.common.planner import TaskPlanner
from apache.thermos.config.loader import ThermosConfigLoader
from apache.thermos.core.runner import TaskRunner


app.add_option(
    "--thermos_json",
    dest="thermos_json",
    default=None,
    help="read a thermos Task from a serialized json blob")


app.add_option(
    "--sandbox",
    dest="sandbox",
    metavar="PATH",
    default=None,
    help="the sandbox in which this task should run")


app.add_option(
     "--checkpoint_root",
     dest="checkpoint_root",
开发者ID:sumanau7,项目名称:incubator-aurora,代码行数:31,代码来源:thermos_runner.py


示例11: NailgunError

    sock = self.try_connect()
    if not sock:
      raise NailgunError('Problem connecting to nailgun server %s:%d' % (self._host, self._port))

    session = NailgunSession(sock, self._ins, self._out, self._err)
    try:
      return session.execute(self._work_dir, main_class, *args, **environment)
    except socket.error as e:
      raise NailgunError('Problem contacting nailgun server %s:%d %s' % (self._host, self._port, e))
    finally:
      sock.close()


app.add_option('--nailgun-version',
               dest='just_version',
               default=False,
               action='store_true',
               help='print product version and exit')

app.add_option('--nailgun-showversion',
               dest='show_version',
               default=False,
               action='store_true',
               help='print product version and continue')

app.add_option('--nailgun-server',
               dest='ng_host',
               metavar='HOST',
               default=DEFAULT_NG_HOST,
               help='to specify the address of the nailgun server (default is %default)')
开发者ID:billwei,项目名称:commons,代码行数:30,代码来源:nailgun_client.py


示例12: main

import os
import sys
import pprint
import time

from gen.twitter.thermos.ttypes import RunnerState, RunnerCkpt, TaskState

from twitter.common import app
from twitter.common.recordio import RecordIO, ThriftRecordReader
from twitter.thermos.common.ckpt import CheckpointDispatcher

app.add_option("--checkpoint", dest = "ckpt", metavar = "CKPT",
               help = "read checkpoint from CKPT")
app.add_option("--assemble", dest = "assemble", metavar = "CKPT", default=True,
               help = "read checkpoint from CKPT")

def main(args):
  values = app.get_options()

  if len(args) > 0:
    print >> sys.stderr, "ERROR: unrecognized arguments: %s\n" % (" ".join(args))
    app.help()
    sys.exit(1)

  if not values.ckpt:
    print >> sys.stderr, "ERROR: must supply --checkpoint"
    app.help()
    sys.exit(1)

  fp = file(values.ckpt, "r")
  rr = ThriftRecordReader(fp, RunnerCkpt)
开发者ID:Empia,项目名称:incubator-aurora,代码行数:31,代码来源:thermos_ckpt.py


示例13: add_verbosity_options

app.register_commands_from(admin, help_commands, maintenance)
add_verbosity_options()


def main():
  app.help()

try:
  from apache.aurora.kerberos.auth_module import KerberosAuthModule
  register_auth_module(KerberosAuthModule())
except ImportError:
  # Use default auth implementation if kerberos is not available.
  pass

LogOptions.set_stderr_log_level('INFO')
LogOptions.disable_disk_logging()
app.set_name('aurora-admin')
app.set_usage(generate_terse_usage())

app.add_option(
    '--bypass-leader-redirect',
    action='store_true',
    default=False,
    dest='bypass_leader_redirect',
    help='Bypass the scheduler\'s leader redirect filter')


def proxy_main():
  app.main()
开发者ID:apache,项目名称:aurora,代码行数:29,代码来源:aurora_admin.py


示例14: TrackerRequest

from collections import defaultdict

from rainman.codec import BEncoder

from twitter.common import app, log
from twitter.common.http import HttpServer
from twitter.common.quantity import Amount, Time


app.add_option(
    '--port',
    dest='port',
    default=8080,
    type=int,
    help='The port on which the torrent tracker should be run.')


class TrackerRequest(object):
  class Error(Exception): pass
  class MalformedRequestError(Error): pass

  REQUIRED_KEYS = frozenset([
    'info_hash',
    'peer_id',
    'port',
    'uploaded',
    'downloaded',
    'left',
  ])

  OPTIONAL_KEYS = set(['ip', 'event'])
开发者ID:pombredanne,项目名称:rainman,代码行数:31,代码来源:tracker.py


示例15: repr

      LogOptions.set_stdout_log_level(value)
    except LogOptionsException, e:
      raise optparse.OptionValueError('Failed to parse option: %s' % e)
    parser.values.twitter_common_log_stdout_log_level = value

_LOGGING_HELP = \
"""The level at which to log to %%s [default: %%%%default].
Takes either LEVEL or scheme:LEVEL, where LEVEL is one
of %s and scheme is one of %s.
""" % (repr(LogOptions._LOG_LEVELS.keys()), repr(LogOptions._LOG_SCHEMES))

if HAVE_APP:
  app.add_option('--log_to_stdout',
              callback=LogOptions._stdout_options_callback,
              default=_DEFAULT_LOG_OPTS.twitter_common_log_stdout_log_level,
              type='string',
              action='callback',
              metavar='[scheme:]LEVEL',
              dest='twitter_common_log_stdout_log_level',
              help=_LOGGING_HELP % 'stdout')

  app.add_option('--log_to_disk',
              callback=LogOptions._disk_options_callback,
              default=_DEFAULT_LOG_OPTS.twitter_common_log_disk_log_level,
              type='string',
              action='callback',
              metavar='[scheme:]LEVEL',
              dest='twitter_common_log_disk_log_level',
              help=_LOGGING_HELP % 'disk')

  app.add_option('--log_dir',
              type='string',
开发者ID:billwei,项目名称:commons,代码行数:32,代码来源:options.py


示例16: setup

def setup():
  app.add_option('--iface', default='eth0', type=str)
  app.add_option('--port', default=3888, type=int)
  app.add_option('-c', '--colors', default=False, action='store_true')
开发者ID:aalzabarah,项目名称:zktraffic,代码行数:4,代码来源:fle.py


示例17:

from jenkinsapi.exceptions import UnknownJob

import os
import sys

from twitter.common import app
from twitter.common import log
from twitter.common import dirutil

from twitter.common.log.options import LogOptions


app.set_usage("jenkins --[server|outdir|config]  [--job=[jobname]] [create|delete|show|enable|disable]")
app.add_option(
  "--server",
  default="ci.makewhat.is:8080",
  dest="server",
  help="jenkins server"
)
app.add_option(
  "--job",
  default=None,
  dest="job",
  help="job name"
)
app.add_option(
  "--config",
  default=None,
  dest="config",
  help="config path"
)
app.add_option(
开发者ID:makewhatis,项目名称:commons,代码行数:32,代码来源:jenkins.py


示例18:

import time

from twitter.common import app
from twitter.common.exceptions import ExceptionalThread
from twitter.common.log.options import LogOptions

from apache.aurora.executor.common.path_detector import MesosPathDetector
from apache.thermos.common.constants import DEFAULT_CHECKPOINT_ROOT
from apache.thermos.monitoring.detector import ChainedPathDetector, FixedPathDetector
from apache.thermos.observer.http.configure import configure_server
from apache.thermos.observer.task_observer import TaskObserver

app.add_option(
    '--root',
    dest='root',
    type='string',
    default=DEFAULT_CHECKPOINT_ROOT,
    help='The thermos checkpoint root directory to search for Thermos tasks [default: %default]')


app.add_option(
    '--mesos-root',
    dest='mesos_root',
    type='string',
    default=MesosPathDetector.DEFAULT_MESOS_ROOT,
    help='The mesos root directory to search for Thermos executor sandboxes [default: %default]')


app.add_option(
    '--port',
    dest='port',
开发者ID:KancerEzeroglu,项目名称:aurora,代码行数:31,代码来源:thermos_observer.py


示例19: proxy_main

def proxy_main():
  app.add_option(
      '--port',
      dest='api_port',
      type='int',
      default=None,
      help='Port for the HTTP API server')

  app.add_option(
      '--mesos_master',
      dest='mesos_master',
      default=None,
      help='Mesos master address. It can be a ZooKeeper URL through which the master can be '
           'detected')

  app.add_option(
      '--framework_user',
      dest='framework_user',
      help='The Unix user that Mysos executor runs as')

  app.add_option(
      '--framework_role',
      dest='framework_role',
      default='*',
      help="The role that Mysos framework runs as. If set, Mysos only uses Mesos pool resources "
           "with that role. The default value '*' is what Mesos considers as the default role.\n"
           "NOTE: Mesos master needs to be configured to allow the specified role. See its --roles "
           "flag")

  app.add_option(
      '--executor_uri',
      dest='executor_uri',
      default=None,
      help='URI for the Mysos executor package')

  app.add_option(
      '--executor_cmd',
      dest='executor_cmd',
      default=None,
      help='Command to execute the executor package')

  app.add_option(
      '--executor_environ',
      dest='executor_environ',
      default=None,
      help="Environment variables for the executors (and the tasks) as a list of dicts keyed by "
           "{name, value} in JSON. Note that these variables don't affect Mesos slave components "
           "such as the fetcher")

  app.add_option(
      '--zk_url',
      dest='zk_url',
      default=None,
      help='ZooKeeper URL for various Mysos operations, in the form of '
           '"zk://username:[email protected]/path". The sub-directory <zk_url>/discover is used for '
           'communicating MySQL cluster information between Mysos scheduler and executors')

  # TODO(jyx): This could also be made a per-cluster configuration.
  app.add_option(
      '--election_timeout',
      dest='election_timeout',
      default='60s',
      help='The amount of time the scheduler waits for all slaves to respond during a MySQL master '
           'election, e.g., 60s. After the timeout the master is elected from only the slaves that '
           'have responded')

  app.add_option(
      '--admin_keypath',
      dest='admin_keypath',
      default=None,
      help='The path to the key file with MySQL admin credentials on Mesos slaves')

  app.add_option(
      '--work_dir',
      dest='work_dir',
      default=os.path.join(tempfile.gettempdir(), 'mysos'),
      help="Directory path to place Mysos work directories, e.g., web assets, state files if "
           "--state_storage=local. Default to a system temp directory.")

  app.add_option(
      '--state_storage',
      dest='state_storage',
      default='zk',
      help="Mechanism to persist scheduler state. Available options are 'zk' and 'local'. If 'zk' "
           "is chosen, the scheduler state is stored under <zk_url>/state; see --zk_url. Otherwise "
           "'local' is chosen and the state is persisted under <work_dir>/state; see --work_dir")

  app.add_option(
      '--framework_failover_timeout',
      dest='framework_failover_timeout',
      default='14d',
      help='Time after which Mysos framework is considered deleted. This implies losing all tasks. '
           'SHOULD BE VERY HIGH')

  # TODO(jyx): Flags like this are generally optional but specific executor implementations may
  # require them. Consider adding validators that can be plugged in so configuration errors can be
  # caught in the scheduler.
  app.add_option(
      '--installer_args',
      dest='installer_args',
#.........这里部分代码省略.........
开发者ID:gpapilion,项目名称:mysos,代码行数:101,代码来源:mysos_scheduler.py


示例20:

from __future__ import print_function

import re

from twitter.common import app

from .common import Nit, PythonFile
from .iterators import git_iterator, path_iterator
from .plugins import list_plugins


app.add_option(
  '-p',
  action='append',
  type='str',
  default=[],
  dest='plugins',
  help='Explicitly list plugins to enable.')


app.add_option(
  '-n',
  action='append',
  type='str',
  default=[],
  dest='skip_plugins',
  help='Explicitly list plugins to disable.')


app.add_option(
开发者ID:EricCen,项目名称:commons,代码行数:30,代码来源:checker.py



注:本文中的twitter.common.app.add_option函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python app.error函数代码示例发布时间:2022-05-27
下一篇:
Python twitter.Twitter类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap