本文整理汇总了Python中twisted.scripts.twistd.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()