本文整理汇总了Python中twisted.application.app.startApplication函数的典型用法代码示例。如果您正苦于以下问题:Python startApplication函数的具体用法?Python startApplication怎么用?Python startApplication使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了startApplication函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startApplication
def startApplication(self, application):
"""
Configure global process state based on the given application and run
the application.
@param application: An object which can be adapted to
L{service.IProcess} and L{service.IService}.
"""
process = service.IProcess(application)
if not self.config['originalname']:
launchWithName(process.processName)
self.setupEnvironment(
self.config['chroot'], self.config['rundir'],
self.config['nodaemon'], self.config['umask'],
self.config['pidfile'])
service.IService(application).privilegedStartService()
uid, gid = self.config['uid'], self.config['gid']
if uid is None:
uid = process.uid
if gid is None:
gid = process.gid
self.shedPrivileges(self.config['euid'], uid, gid)
app.startApplication(application, not self.config['no_save'])
示例2: siptrackd_twisted_init
def siptrackd_twisted_init(object_store, application):
log.msg('Loading object store, this might take a while')
yield object_store.init()
log.msg('Object store loading complete')
log.msg('Starting rpc listener')
app.startApplication(application, False)
log.msg('Running')
示例3: daemon
def daemon():
from twisted.internet import glib2reactor
glib2reactor.install()
from twisted.internet import reactor
main_app = Application("Audio Failure Monitor") #, uid, gid)
services = IServiceCollection(main_app)
options = DaemonOptions()
options.parseOptions()
application = options.getService()
application.infotub.setServiceParent(services)
application.coretub.setServiceParent(services)
app.startApplication(main_app, False)
reactor.addSystemEventTrigger('before', 'shutdown',
logging.getLogger(__name__).info,
'Stopping AFM')
logging.getLogger(__name__).info("AFM Started")
try:
reactor.run()
except KeyboardInterrupt:
reactor.stop()
示例4: execute
def execute(config_file):
global config
config = _get_config(config_file)
log.startLogging(sys.stderr)
application = get_application(config)
app.startApplication(application, False)
reactor.run() #@UndefinedVariable
示例5: handle_noargs
def handle_noargs(self, *args, **options):
## ! XXX: `from django.utils import autoreload`? Might put it into
## xmppface or xmppwoker
from xmppface.s2scfg import cfg_override
from xmppface.s2sbase import setup_twisted_app
application = setup_twisted_app(cfg_override(settings))
startApplication(application, False)
reactor.run()
示例6: runApp
def runApp(res):
"""
Start the actual service Application.
"""
log.debug("[D] %s %s " % (__file__, __name__), "Class GLBaseRunner", "preApplication", "runApp")
service.IService(self.application).privilegedStartService()
app.startApplication(self.application, not self.config['no_save'])
app.startApplication(internet.TimerService(0.1, lambda:None), 0)
startAsynchronous()
示例7: postApplication
def postApplication(self):
"""
Start the application and run the reactor.
"""
service.IService(self.application).privilegedStartService()
app.startApplication(self.application, not self.config['no_save'])
app.startApplication(internet.TimerService(0.1, lambda:None), 0)
self.startReactor(None, self.oldstdout, self.oldstderr)
log.msg("Server Shut Down.")
示例8: execute
def execute():
try:
config = _get_config()
except NotConfigured:
config = None
log.startLogging(sys.stderr)
application = get_application(config)
app.startApplication(application, False)
reactor.run()
示例9: postApplication
def postApplication(self):
"""
Start the application and run the reactor.
"""
service.IService(self.application).privilegedStartService()
app.startApplication(self.application, not self.config['no_save'])
app.startApplication(internet.TimerService(0.1, lambda:None), 0)
app.runReactorWithLogging(self.config, self.oldstdout, self.oldstderr)
app.reportProfile(self.config['report-profile'],
service.IProcess(self.application).processName)
log.msg("Server Shut Down.")
示例10: run
def run():
if platform.system() != "Windows":
if not sys.modules.has_key('twisted.internet.reactor'):
print "installing poll reactor"
pollreactor.install()
else:
print "poll reactor already installed"
from twisted.internet import reactor
application = makeApplication(sys.argv)
app.startApplication(application, None)
from twisted.internet import pollreactor
reactor.run()
示例11: start
def start(self, portno=None):
import sys
lfname = self['logfile']
if lfname == '-':
lf = sys.stdout
else:
lf = file(os.path.expanduser(lfname), 'ab+')
log.startLogging(lf,
setStdout=False)
srv = self.getService()
from twisted.application.app import startApplication
startApplication(srv, False)
reactor.run()
示例12: run
def run(appName):
application = service.Application(appName)
from sparked import tap
config = tap.Options()
config.parseOptions(sys.argv[1:])
svc = tap.makeService(config)
svc.setServiceParent(application)
app.startApplication(application, False)
log.addObserver(log.FileLogObserver(sys.stdout).emit)
reactor.run()
示例13: run
def run():
twisted_log.startLogging(sys.stdout)
if platform.system() != "Windows":
if 'twisted.internet.reactor' not in sys.modules:
log.debug("installing epoll reactor")
from twisted.internet import epollreactor
epollreactor.install()
else:
log.debug("reactor already installed")
from twisted.internet import reactor
application = makeApplication(sys.argv)
app.startApplication(application, None)
reactor.run()
示例14: execute
def execute():
sys.path.insert(0, os.getcwd())
arguments = parse_arguments()
if arguments.settings:
settings.setmodule(arguments.settings)
if arguments.set:
for name, value in arguments.set:
settings.set(name.upper(), value)
settings.set('PROJECT_SETTINGS', find_scrapy_project(arguments.project))
settings.freeze()
setup_logging()
application = get_application(arguments)
app.startApplication(application, save=False)
reactor.run()
示例15: start_services
def start_services(config):
client = XMPPClient(jid.internJID(config.credentials['jid']), config.credentials['password'])
application = service.Application('commitbot')
bot = CommitBot(config)
bot.setHandlerParent(client)
site = server.Site(WebHook(config, bot))
tcp_server = reactor.listenTCP(8888, site)
app.startApplication(application, None)
client.startService()
reactor.run()