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

Python twistd.run函数代码示例

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

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



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

示例1: start

def start(opts, out=sys.stdout, err=sys.stderr):
    basedir = opts['basedir']
    print >>out, "STARTING", quote_output(basedir)
    if not os.path.isdir(basedir):
        print >>err, "%s does not look like a directory at all" % quote_output(basedir)
        return 1
    for fn in listdir_unicode(basedir):
        if fn.endswith(u".tac"):
            tac = str(fn)
            break
    else:
        print >>err, "%s does not look like a node directory (no .tac file)" % quote_output(basedir)
        return 1
    if "client" in tac:
        nodetype = "client"
    elif "introducer" in tac:
        nodetype = "introducer"
    else:
        nodetype = "unknown (%s)" % tac

    args = ["twistd", "-y", tac]
    if opts["syslog"]:
        args.append("--syslog")
    elif nodetype in ("client", "introducer"):
        fileutil.make_dirs(os.path.join(basedir, "logs"))
        args.extend(["--logfile", os.path.join("logs", "twistd.log")])
    if opts["profile"]:
        args.extend(["--profile=profiling_results.prof", "--savestats",])
    # now we're committed
    os.chdir(basedir)
    from twisted.scripts import twistd
    sys.argv = args
    twistd.run()
开发者ID:drewp,项目名称:tahoe-lafs,代码行数:33,代码来源:startstop_node.py


示例2: start

def start(path, _test=False):
    """Start the readerd instance.
    """
    tac_file = os.path.join(path, "readerd.tac")
    if not os.path.exists(tac_file):
        if not _test:
            sys.stderr.write("unable to locate {}, exiting\n".format(tac_file))
        return 1
    os.chdir(path)
    sys.path.insert(0, os.path.abspath(os.getcwd()))

    argv = [
        "twistd",
        "--no_save",
        "--logfile=twistd.log",
        "--python=readerd.tac"
    ]
    sys.argv = argv

    if _test:
        # Do not try to start twistd during unittesting
        return 0

    # Starting twistd
    from twisted.scripts import twistd
    sys.stdout.write("readerd process is starting\n")
    twistd.run()
开发者ID:tonylazarew,项目名称:reader,代码行数:27,代码来源:launcher.py


示例3: debug

def debug(options):
    '''Run the buildslave without forking in background.'''

    # Set buildslave name to be used in buildbot.tac.
    sys.buildslave_name = pave.getOption(
        options, 'debug', 'name', default_value=pave.getHostname())

    argv = [
        'twistd',
        '--no_save',
        '--nodaemon',
        '--logfile=-',
        '--python=buildbot.tac',
        ]
    sys.argv = argv

    try:
        from setproctitle import setproctitle
        setproctitle  # Shut up the linter.
    except ImportError:
        setproctitle = lambda t: None

    setproctitle('buildbot-slave')

    from twisted.scripts import twistd
    with pushd(pave.fs.join([pave.path.build, 'slave'])):
        twistd.run()
开发者ID:chevah,项目名称:buildslave-deployment,代码行数:27,代码来源:pavement.py


示例4: entrypoint

 def entrypoint():
     import sys
     from os import path
     app = path.join(path.dirname(__file__),name)
     sys.argv.insert(1, app)
     sys.argv.insert(1, '-y')
     from twisted.scripts.twistd import run
     run()
开发者ID:UndeRus,项目名称:bnw,代码行数:8,代码来源:entry.py


示例5: main

def main(args):
    cmdLine = run.calcCommandline()
    places = run.mkconfig('boredbot-config')
    ctllib.add(places, 'boredbot', cmd=cmdLine[0], args=cmdLine[1:] + ['loop'],
               env=['SECRET_KEY='+os.environ['SECRET_KEY']])
    ctllib.add(places, 'boredweb', cmd=cmdLine[0], args=cmdLine[1:] + ['gunicorn', '--bind', '0.0.0.0:8000', '-w', '4', 'boredbot_deploy.wsgi:app'],
               env=['SECRET_KEY='+os.environ['SECRET_KEY']])
    sys.argv = ['twistd', '--nodaemon', 'ncolony', '--messages', places.messages, '--config', places.config]
    twistd.run()
开发者ID:moshez,项目名称:boredbot,代码行数:9,代码来源:start.py


示例6: run_twistd

def run_twistd(args1=None, args2=None):
  args = [sys.argv[0]]
  if args1 is not None:
    args.extend(args1)
  args.append("qwebirc")
  if args2 is not None:
    args.extend(args2)
  sys.argv = args
  run()
开发者ID:550,项目名称:brouhaha,代码行数:9,代码来源:run.py


示例7: spawn

def spawn(opts, conf):
    """ Acts like twistd """
    if opts.config is not None:
        os.environ["CALLSIGN_CONFIG_FILE"] = opts.config
    sys.argv[1:] = [
        "-noy", sibpath(__file__, "callsign.tac"),
        "--pidfile", conf['pidfile'],
        "--logfile", conf['logfile'],
    ]
    twistd.run()
开发者ID:yaybu,项目名称:callsign,代码行数:10,代码来源:daemon.py


示例8: run_with_twistd

def run_with_twistd(options, application_name=''):
	from twisted.scripts.twistd import run
	opts = ['-l', '/dev/null']
	if options:
		opts.extend(options)
	sys.argv[1:] = opts

	application = service.Application(application_name)
	service.loadApplication = lambda f, k, p=None: application
	run()
开发者ID:reith,项目名称:ashttp,代码行数:10,代码来源:runner.py


示例9: run_twistd

def run_twistd(args1=None, args2=None):
  from twisted.scripts.twistd import run
  args = [sys.argv[0]]
  if args1 is not None:
    args.extend(args1)
  args.append("qwebirc")
  if args2 is not None:
    args.extend(args2)
  sys.argv = args
  run()
开发者ID:Stanford-Online,项目名称:edx_irc_chat,代码行数:10,代码来源:run.py


示例10: handle

 def handle(self, *args, **kwargs): # pylint: disable=W0613
     argv = [
         '-y', os.path.join(os.path.dirname(application.__file__),
                            "application.py"),
     ]
     if settings.COMMANDER_PID_FILE is None:
         argv.append('--nodaemon')
     else:
         argv.extend(['--pidfile', settings.COMMANDER_PID_FILE])
     sys.argv[1:] = argv
     run()
开发者ID:IL2HorusTeam,项目名称:il2ds-events-commander,代码行数:11,代码来源:run_commander.py


示例11: execute

def execute(argv, options):
    args = [ sys.argv[0] ]
    if argv is not None:
        args.extend(argv)
    args.append('thor')
    if options is not None:
        args.extend(options)
    sys.argv = args 

    # TODO Debug log message of application arguments
    from twisted.scripts.twistd import run; run() 
    # End of application execution. The main thread will exit after the reactor dies
    # in the execute method we will fall through to this point
    __logAndShutdown() 
开发者ID:Arconiaprime,项目名称:thor,代码行数:14,代码来源:run.py


示例12: run_bitmaskd

def run_bitmaskd():
    # TODO --- configure where to put the logs... (get --logfile, --logdir
    # from the bitmask_cli
    argv[1:] = [
        "-y",
        join(dirname(bitmask_core.__file__), "bitmaskd.tac"),
        "--pidfile",
        "/tmp/bitmaskd.pid",
        "--logfile",
        "/tmp/bitmaskd.log",
        "--umask=0022",
    ]
    print "[+] launching bitmaskd..."
    run()
开发者ID:kalikaneko,项目名称:bitmask_core,代码行数:14,代码来源:launcher.py


示例13: run

    def run(self, options):
        basedir = options.basedir
        stderr = options.stderr
        for fn in os.listdir(basedir):
            if fn.endswith(".tac"):
                tac = fn
                break
        else:
            print >>stderr, "%s does not look like a node directory (no .tac file)" % basedir
            return 1

        os.chdir(options.basedir)
        twistd_args = list(options.twistd_args)
        sys.argv[1:] = ["--no_save", "--python", tac] + twistd_args
        print >>stderr, "Launching Server..."
        twistd.run()
开发者ID:ducki2p,项目名称:foolscap,代码行数:16,代码来源:cli.py


示例14: launchNoDaemon

def launchNoDaemon(config):
    os.chdir(config['basedir'])
    sys.path.insert(0, os.path.abspath(config['basedir']))

    argv = ["twistd",
            "--no_save",
            '--nodaemon',
            "--logfile=twistd.log",  # windows doesn't use the same default
            "--python=buildbot.tac"]
    sys.argv = argv

    # this is copied from bin/twistd. twisted-2.0.0 through 2.4.0 use
    # _twistw.run . Twisted-2.5.0 and later use twistd.run, even for
    # windows.
    from twisted.scripts import twistd
    twistd.run()
开发者ID:dinatale2,项目名称:buildbot,代码行数:16,代码来源:start.py


示例15: launch

def launch(config):
    sys.path.insert(0, os.path.abspath(os.getcwd()))

    # see if we can launch the application without actually having to
    # spawn twistd, since spawning processes correctly is a real hassle
    # on windows.
    argv = ["twistd",
            "--no_save",
            "--logfile=twistd.log", # windows doesn't use the same default
            "--python=buildbot.tac"]
    sys.argv = argv

    # this is copied from bin/twistd. twisted-2.0.0 through 2.4.0 use
    # _twistw.run . Twisted-2.5.0 and later use twistd.run, even for
    # windows.
    from twisted.scripts import twistd
    twistd.run()
开发者ID:Callek,项目名称:buildbot,代码行数:17,代码来源:startup.py


示例16: run_server

def run_server():

    # maybe print version and exit
    args = parse_args()
    if args.version:
        print __version__
        return

    # launch soledad server using twistd
    tac = os.path.join(here(server), 'server.tac')
    args = [
        '--nodaemon',
        '--pidfile=',
        '--syslog',
        '--prefix=soledad-server',
        '--python=%s' % tac,
    ]
    sys.argv[1:] = args
    run()
开发者ID:leapcode,项目名称:soledad,代码行数:19,代码来源:launcher.py


示例17: launch

def launch(nodaemon):
    sys.path.insert(0, os.path.abspath(os.getcwd()))

    # see if we can launch the application without actually having to
    # spawn twistd, since spawning processes correctly is a real hassle
    # on windows.
    from twisted.python.runtime import platformType
    from twisted.scripts.twistd import run
    argv = ["twistd",
            "--no_save",
            "--logfile=twistd.log",  # windows doesn't use the same default
            "--python=buildbot.tac"]
    if nodaemon:
        argv.extend(["--nodaemon"])
        if platformType != 'win32':
            # windows doesn't use pidfile option.
            argv.extend(["--pidfile="])

    sys.argv = argv
    run()
开发者ID:cmouse,项目名称:buildbot,代码行数:20,代码来源:start.py


示例18: launch

def launch(config):
    sys.path.insert(0, os.path.abspath(os.getcwd()))
    if os.path.exists("/usr/bin/make") and os.path.exists("Makefile.buildbot"):
        # Preferring the Makefile lets slave admins do useful things like set
        # up environment variables for the buildslave.
        cmd = "make -f Makefile.buildbot start"
        if not config['quiet']:
            print cmd
        os.system(cmd)
    else:
        # see if we can launch the application without actually having to
        # spawn twistd, since spawning processes correctly is a real hassle
        # on windows.
        argv = ["twistd",
                "--no_save",
                "--logfile=twistd.log", # windows doesn't use the same default
                "--python=buildbot.tac"]
        sys.argv = argv

        # this is copied from bin/twistd. twisted-2.0.0 through 2.4.0 use
        # _twistw.run . Twisted-2.5.0 and later use twistd.run, even for
        # windows.
        from twisted.scripts import twistd
        twistd.run()
开发者ID:Fieldbyte,项目名称:buildbot,代码行数:24,代码来源:startup.py


示例19: main


#.........这里部分代码省略.........
        os.path.dirname(sys.executable),
        os.path.join(os.environ['SYSTEMROOT'], 'system32'),
        os.path.join(os.environ['SYSTEMROOT'], 'system32', 'WBEM'),
        # Use os.sep to make this absolute, not relative.
        os.path.join(os.environ['SYSTEMDRIVE'], os.sep, 'Program Files',
                     '7-Zip'),
    ]
    # build_internal/tools contains tools we can't redistribute.
    tools = os.path.join(ROOT_DIR, 'build_internal', 'tools')
    if os.path.isdir(tools):
      slave_path.append(os.path.abspath(tools))
    os.environ['PATH'] = os.pathsep.join(slave_path)
    os.environ['LOGNAME'] = os.environ['USERNAME']

  elif sys.platform in ('darwin', 'posix', 'linux2'):
    # list of all variables that we want to keep
    env_var = [
        'CCACHE_DIR',
        'CHROME_ALLOCATOR',
        'CHROME_HEADLESS',
        'CHROME_VALGRIND_NUMCPUS',
        'DISPLAY',
        'DISTCC_DIR',
        'GIT_USER_AGENT',
        'HOME',
        'HOSTNAME',
        'HTTP_PROXY',
        'http_proxy',
        'HTTPS_PROXY',
        'LANG',
        'LOGNAME',
        'PAGER',
        'PATH',
        'PWD',
        'PYTHONPATH',
        'SHELL',
        'SSH_AGENT_PID',
        'SSH_AUTH_SOCK',
        'SSH_CLIENT',
        'SSH_CONNECTION',
        'SSH_TTY',
        'TESTING_MASTER',
        'TESTING_MASTER_HOST',
        'TESTING_SLAVENAME',
        'USER',
        'USERNAME',
    ]

    remove_all_vars_except(os.environ, env_var)
    slave_path = [
        os.path.join(os.path.expanduser('~'), 'slavebin'),
        depot_tools,
    ]
    # Git on mac is installed from git-scm.com/download/mac
    if sys.platform == 'darwin' and os.path.isdir('/usr/local/git/bin'):
      slave_path.append('/usr/local/git/bin')
    slave_path += [
        # Reuse the python executable used to start this script.
        os.path.dirname(sys.executable),
        '/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin'
    ]
    os.environ['PATH'] = os.pathsep.join(slave_path)

  else:
    error('Platform %s is not implemented yet' % sys.platform)

  git_exe = 'git' + ('.bat' if sys.platform.startswith('win') else '')
  try:
    git_version = subprocess.check_output([git_exe, '--version'])
  except (OSError, subprocess.CalledProcessError) as e:
    Log('WARNING: Could not get git version information: %r' % e)
    git_version = '?'
  os.environ.setdefault('GIT_USER_AGENT', '%s git/%s %s' % (
      sys.platform, git_version.rstrip().split()[-1], socket.getfqdn()))
  # This may be redundant, unless this is imported and main is called.
  UseBotoPath()

  # This envrionment is defined only when testing the slave on a dev machine.
  is_testing = 'TESTING_MASTER' in os.environ
  if not is_testing:
    # Don't overwrite the ~/.subversion/config file when TESTING_MASTER is set.
    FixSubversionConfig()
  HotPatchSlaveBuilder(is_testing)

  import twisted.scripts.twistd as twistd
  twistd.run()
  shutdown_file = os.path.join(os.path.dirname(__file__), 'shutdown.stamp')
  if os.path.isfile(shutdown_file):
    # If this slave is being shut down gracefully, don't reboot it.
    try:
      os.remove(shutdown_file)
      # Only disable reboot if the file can be removed.  Otherwise, the slave
      # might get stuck offline after every build.
      global needs_reboot
      needs_reboot = False
    except OSError:
      Log('Could not delete graceful shutdown signal file %s' % shutdown_file)
  if needs_reboot:
    # Send the appropriate system shutdown command.
    Reboot()
开发者ID:alexmos17,项目名称:build_internal,代码行数:101,代码来源:run_slave.py


示例20: Copyright

#!C:\Users\xcpro\ve1\Scripts\python.exe
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
import os, sys

try:
    import _preamble
except ImportError:
    sys.exc_clear()

sys.path.insert(0, os.path.abspath(os.getcwd()))

from twisted.scripts.twistd import run
run()
开发者ID:xacprod,项目名称:ve1,代码行数:14,代码来源:twistd.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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