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

Python app.main函数代码示例

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

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



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

示例1: proxy_main

def proxy_main():
  def main(args, opts):
    if args:
      print("ERROR: unrecognized arguments: %s\n" % (" ".join(args)), file=sys.stderr)
      app.help()
      sys.exit(1)

    root_server = HttpServer()
    root_server.mount_routes(DiagnosticsEndpoints())

    task_observer = TaskObserver(opts.root)
    task_observer.start()

    bottle_wrapper = BottleObserver(task_observer)

    root_server.mount_routes(bottle_wrapper)

    def run():
      root_server.run('0.0.0.0', opts.port, 'cherrypy')

    et = ExceptionalThread(target=run)
    et.daemon = True
    et.start()
    et.join()

  app.main()
开发者ID:Empia,项目名称:incubator-aurora,代码行数:26,代码来源:thermos_observer.py


示例2: proxy_main

def proxy_main():
  def main(args, options):
    if MesosExecutorDriver is None:
      app.error('Could not load MesosExecutorDriver!')

    thermos_executor = initialize(options)

    # Create driver stub
    driver = MesosExecutorDriver(thermos_executor)

    # This is an ephemeral executor -- shutdown if we receive no tasks within a certain
    # time period
    ExecutorTimeout(thermos_executor.launched, driver).start()

    # Start executor and wait until it is stopped.
    driver_thread = ExecutorDriverThread(driver)
    driver_thread.start()
    try:
      while driver_thread.isAlive():
        driver_thread.join(5)
    except (KeyboardInterrupt, SystemExit):
      driver.stop()
      raise

    log.info('MesosExecutorDriver.run() has finished.')

  app.register_module(ExceptionTerminationHandler())
  app.main()
开发者ID:apache,项目名称:aurora,代码行数:28,代码来源:thermos_executor_main.py


示例3: proxy_main

def proxy_main():
  def main(args, options):
    thermos_runner_provider = DefaultThermosTaskRunnerProvider(
        dump_runner_pex(),
        artifact_dir=os.path.realpath('.'),
    )

    # status providers:
    status_providers = [HealthCheckerProvider()]

    if options.announcer_enable:
      if options.announcer_ensemble is None:
        app.error('Must specify --announcer-ensemble if the announcer is enabled.')
      status_providers.append(DefaultAnnouncerCheckerProvider(
          options.announcer_ensemble, options.announcer_serverset_path))

    # Create executor stub
    thermos_executor = AuroraExecutor(
        runner_provider=thermos_runner_provider,
        status_providers=status_providers,
    )

    # Create driver stub
    driver = MesosExecutorDriver(thermos_executor)

    # This is an ephemeral executor -- shutdown if we receive no tasks within a certain
    # time period
    ExecutorTimeout(thermos_executor.launched, driver).start()

    # Start executor
    driver.run()

    log.info('MesosExecutorDriver.run() has finished.')

  app.main()
开发者ID:aalzabarah,项目名称:incubator-aurora,代码行数:35,代码来源:thermos_executor_main.py


示例4: proxy_main

def proxy_main():
    """Proxy main function.

    setuptools entrypoints with twitter.common.app is so awkward.
    """
    def main(_, opts):
        """Main"""

        if not opts.bucket:
            log.error('--bucket is required.')
            app.help()

        server = S3Web(bucket=opts.bucket,
                       prefix=opts.prefix,
                       access_key_id=opts.access_key_id,
                       secret_key=opts.secret_key)
        thread = ExceptionalThread(
            target=lambda: server.run(opts.listen,
                                      opts.port,
                                      server='cherrypy'))
        thread.daemon = True
        thread.start()

        log.info('Ready.')
        app.wait_forever()

    register_opts()
    app.set_usage(__doc__)
    app.set_option('twitter_common_log_stderr_log_level', 'google:INFO')
    app.set_name('s3webfront')
    app.main()
开发者ID:benley,项目名称:s3webfront,代码行数:31,代码来源:s3webfront.py


示例5: proxy_main

def proxy_main():
  def main():
    runner_provider = DefaultThermosTaskRunnerProvider(
        dump_runner_pex(),
        artifact_dir=os.path.realpath('.'),
    )

    # Create executor stub
    thermos_executor = ThermosExecutor(
        runner_provider=runner_provider,
        status_providers=(HealthCheckerProvider(),),
    )

    # Create driver stub
    driver = mesos.MesosExecutorDriver(thermos_executor)

    # This is an ephemeral executor -- shutdown if we receive no tasks within a certain
    # time period
    ExecutorTimeout(thermos_executor.launched, driver).start()

    # Start executor
    driver.run()

    log.info('MesosExecutorDriver.run() has finished.')

  app.main()
开发者ID:betepahos,项目名称:incubator-aurora,代码行数:26,代码来源:thermos_executor_main.py


示例6: 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


示例7: proxy_main

def proxy_main():
  def main(args, options):
    if MesosExecutorDriver is None:
      app.error('Could not load MesosExecutorDriver!')

    # status providers:
    status_providers = [
        HealthCheckerProvider(),
        ResourceManagerProvider(checkpoint_root=options.checkpoint_root)
    ]

    if options.announcer_enable:
      if options.announcer_ensemble is None:
        app.error('Must specify --announcer-ensemble if the announcer is enabled.')
      status_providers.append(DefaultAnnouncerCheckerProvider(
        options.announcer_ensemble, options.announcer_serverset_path))

    # Create executor stub
    if options.execute_as_user or options.nosetuid:
      # If nosetuid is set, execute_as_user is also None
      thermos_runner_provider = UserOverrideThermosTaskRunnerProvider(
        dump_runner_pex(),
        artifact_dir=os.path.abspath(CWD)
      )
      thermos_runner_provider.set_role(None)

      thermos_executor = AuroraExecutor(
        runner_provider=thermos_runner_provider,
        status_providers=status_providers,
        sandbox_provider=UserOverrideDirectorySandboxProvider(options.execute_as_user)
      )
    else:
      thermos_runner_provider = DefaultThermosTaskRunnerProvider(
        dump_runner_pex(),
        artifact_dir=os.path.abspath(CWD)
      )

      thermos_executor = AuroraExecutor(
        runner_provider=thermos_runner_provider,
        status_providers=status_providers
      )

    # Create driver stub
    driver = MesosExecutorDriver(thermos_executor)

    # This is an ephemeral executor -- shutdown if we receive no tasks within a certain
    # time period
    ExecutorTimeout(thermos_executor.launched, driver).start()

    # Start executor
    driver.run()

    log.info('MesosExecutorDriver.run() has finished.')

  app.main()
开发者ID:KancerEzeroglu,项目名称:aurora,代码行数:55,代码来源:thermos_executor_main.py


示例8: proxy_main

def proxy_main():
  def main(args, options):
    plugins = list_plugins()

    if options.list_plugins:
      for plugin in plugins:
        print('\n%s' % plugin.__name__)
        if plugin.__doc__:
          for line in plugin.__doc__.splitlines():
            print('    %s' % line)
        else:
          print('    No information')
      return

    if options.plugins:
      plugins_map = dict((plugin.__name__, plugin) for plugin in plugins)
      plugins = list(filter(None, map(plugins_map.get, options.plugins)))

    if options.skip_plugins:
      plugins_map = dict((plugin.__name__, plugin) for plugin in plugins)
      for plugin in options.skip_plugins:
        plugins_map.pop(plugin, None)
      plugins = list(plugins_map.values())

    if not args and options.diff is None:
      options.diff = DEFAULT_BRANCH

    if options.diff:
      iterator = git_iterator(args, options)
    else:
      iterator = path_iterator(args, options)

    severity = Nit.COMMENT
    for number, name in Nit.SEVERITY.items():
      if name == options.severity:
        severity = number

    should_fail = False
    for filename, line_filter in iterator:
      try:
        python_file = PythonFile.parse(filename)
      except SyntaxError as e:
        print('%s:SyntaxError: %s' % (filename, e))
        continue
      for checker in plugins:
        for nit in apply_filter(python_file, checker, line_filter):
          if nit.severity >= severity:
            print(nit)
            print()
          should_fail |= nit.severity >= Nit.ERROR or (
              nit.severity >= Nit.WARNING and options.strict)

    return int(should_fail)

  app.main()
开发者ID:AdamEther,项目名称:pajamas,代码行数:55,代码来源:checker.py


示例9: proxy_main

def proxy_main():
  def main(args, options):
    log.info('Starting testing mysos executor')

    executor = MysosExecutor(
        FakeTaskRunnerProvider(FakeTaskControlProvider()), Sandbox(SANDBOX_ROOT))

    driver = mesos.native.MesosExecutorDriver(executor)
    driver.run()

    log.info('Exiting executor main')

  app.main()
开发者ID:GavinHwa,项目名称:mysos,代码行数:13,代码来源:fake_mysos_executor.py


示例10: run

def run():
  def main(_, opts):
    path_detector = FixedPathDetector(opts.root)
    task_observer = TaskObserver(path_detector)
    task_observer.start()
    server = configure_server(task_observer)

    thread = ExceptionalThread(target=lambda: server.run('0.0.0.0', opts.port, 'cherrypy'))
    thread.daemon = True
    thread.start()

    sleep_forever()

  app.main()
开发者ID:KancerEzeroglu,项目名称:aurora,代码行数:14,代码来源:thermos_observer.py


示例11: proxy_main

def proxy_main():
  def main():
    if MesosExecutorDriver is None:
      app.error('Could not load MesosExecutorDriver!')

    thermos_gc_executor, metric_writer, driver = initialize()

    thermos_gc_executor.start()
    metric_writer.start()
    driver.run()

    log.info('MesosExecutorDriver.run() has finished.')

  app.main()
开发者ID:caofangkun,项目名称:apache-aurora,代码行数:14,代码来源:gc_executor_main.py


示例12: proxy_main

def proxy_main():
  def main():
    # Create executor stub
    thermos_gc_executor = ThermosGCExecutor(checkpoint_root=TaskPath.DEFAULT_CHECKPOINT_ROOT)
    thermos_gc_executor.start()

    # Start metrics collection
    metric_writer = DiskMetricWriter(thermos_gc_executor.metrics, ExecutorDetector.VARS_PATH)
    metric_writer.start()

    # Create driver stub
    driver = mesos.MesosExecutorDriver(thermos_gc_executor)

    # Start GC executor
    driver.run()

    log.info('MesosExecutorDriver.run() has finished.')

  app.main()
开发者ID:Empia,项目名称:incubator-aurora,代码行数:19,代码来源:gc_executor_main.py


示例13: proxy_main

def proxy_main():
  def main(args, options):
    if MesosExecutorDriver is None:
      app.error('Could not load MesosExecutorDriver!')

    thermos_executor = initialize(options)

    # Create driver stub
    driver = MesosExecutorDriver(thermos_executor)

    # This is an ephemeral executor -- shutdown if we receive no tasks within a certain
    # time period
    ExecutorTimeout(thermos_executor.launched, driver).start()

    # Start executor
    driver.run()

    log.info('MesosExecutorDriver.run() has finished.')

  app.main()
开发者ID:BruceZu,项目名称:aurora,代码行数:20,代码来源:thermos_executor_main.py


示例14: proxy_main

def proxy_main():
  def main():
    if MesosExecutorDriver is None:
      app.error('Could not load MesosExecutorDriver!')

    # Create executor stub
    thermos_gc_executor = ThermosGCExecutor(FixedPathDetector(DEFAULT_CHECKPOINT_ROOT))
    thermos_gc_executor.start()

    # Start metrics collection
    metric_writer = DiskMetricWriter(thermos_gc_executor.metrics, ExecutorDetector.VARS_PATH)
    metric_writer.start()

    # Create driver stub
    driver = MesosExecutorDriver(thermos_gc_executor)

    # Start GC executor
    driver.run()

    log.info('MesosExecutorDriver.run() has finished.')

  app.main()
开发者ID:KancerEzeroglu,项目名称:aurora,代码行数:22,代码来源:gc_executor_main.py


示例15: proxy_main

def proxy_main():
  def main(args, options):
    # 'sandbox' directory resides under the working directory assigned by the Mesos slave.
    sandbox_root = os.path.join(os.path.realpath('.'), "sandbox")

    unpack_assets(sandbox_root, MYSOS_MODULE, ASSET_RELPATH, execute=chmod_scripts)

    log.info("Starting Vagrant Mysos executor within sandbox %s" % sandbox_root)

    sandbox = Sandbox(sandbox_root)
    executor = MysosExecutor(
        MysosTaskRunnerProvider(
            MySQLTaskControlProvider(),
            NoopPackageInstallerProvider(),  # Do not install any package.
            NoopBackupStoreProvider()),  # Do not recover any state.
        sandbox)
    driver = mesos.native.MesosExecutorDriver(executor)
    driver.run()

    log.info('Exiting executor main')

  app.main()
开发者ID:GavinHwa,项目名称:mysos,代码行数:22,代码来源:vagrant_mysos_executor.py


示例16: run

def run():
    def main(args, opts):
        """Main"""
        zkconn = kazoo_client.TwitterKazooClient(opts.zk)
        zkconn.start()

        server = RedirServer(zkconn, opts.zk_basepath, opts.scheduler_url,
                             opts.subdomain, opts.base_domain)
        thread = ExceptionalThread(
            target=lambda: server.run(opts.listen,
                                      opts.port,
                                      server='cherrypy'))
        thread.daemon = True
        thread.start()

        # Wait forever, basically.
        thread.join()

    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',
                   help='Zookeeper ensemble (comma-delimited)',
                   default='zookeeper:2181')
    app.add_option('--zk_basepath',
                   help='Zookeeper service path root.',
                   default='/aurora/svc')
    app.add_option('--scheduler_url',
                   help='Aurora scheduler URL')
    app.add_option('--base_domain',
                   help='Domain name of your site.')
    app.add_option('--subdomain',
                   help='Subdomain that roots Aurora job namespace.',
                   default='aurora')

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


示例17: proxy_main

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


示例18: proxy_main

def proxy_main():
  main = runner_proxy_main

  app.main()
开发者ID:MustafaOrkunAcar,项目名称:incubator-aurora,代码行数:4,代码来源:thermos_runner_main.py


示例19: main

def main(args):
  options = app.get_options()
  if options.show_help:
    app.help()

  if options.show_version or options.just_version:
    print >> sys.stdout, 'Python NailGun client version 0.0.1'
    if options.just_version:
      sys.exit(0)


  # Assume ng.pex has been aliased to the command name
  command = re.compile('.pex$').sub('', os.path.basename(sys.argv[0]))
  args_index = 0

  # Otherwise the command name is the 1st arg
  if command == 'ng':
    if not args:
      app.help()

    command = args[0]
    args_index = 1

  ng = NailgunClient(host=options.ng_host, port=options.ng_port)
  result = ng(command, *args[args_index:], **os.environ)
  sys.exit(result)


app.main()
开发者ID:billwei,项目名称:commons,代码行数:29,代码来源:nailgun_client.py


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python collections.maybe_list函数代码示例发布时间:2022-05-27
下一篇:
Python app.get_options函数代码示例发布时间: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