本文整理汇总了Python中twisted.internet.protocol.ServerFactory.doStart方法的典型用法代码示例。如果您正苦于以下问题:Python ServerFactory.doStart方法的具体用法?Python ServerFactory.doStart怎么用?Python ServerFactory.doStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.protocol.ServerFactory
的用法示例。
在下文中一共展示了ServerFactory.doStart方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doStart
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import doStart [as 别名]
def doStart(self):
ServerFactory.doStart(self)
# Wait for AMQP to get ready
self.log.info("Waiting for AMQP to get ready")
yield self.pb['smppcm'].amqpBroker.channelReady
# Load configuration profile
proto = self.buildProtocol(('127.0.0.1', 0))
tr = proto_helpers.StringTransport()
proto.makeConnection(tr)
if (self.config.authentication and self.loadConfigProfileWithCreds['username'] is not None
and self.loadConfigProfileWithCreds['password'] is not None):
self.log.info(
"OnStart loading configuration default profile with username: '%s'",
self.loadConfigProfileWithCreds['username'])
if (self.loadConfigProfileWithCreds['username'] != self.config.admin_username or
md5(self.loadConfigProfileWithCreds['password']).digest() != self.config.admin_password):
self.log.error(
"Authentication error, cannot load configuration profile with provided username: '%s'",
self.loadConfigProfileWithCreds['username'])
proto.connectionLost(None)
defer.returnValue(False)
proto.dataReceived('%s\r\n' % self.loadConfigProfileWithCreds['username'])
proto.dataReceived('%s\r\n' % self.loadConfigProfileWithCreds['password'])
elif self.config.authentication:
self.log.error(
'Authentication is required and no credentials given, config. profile will not be loaded')
proto.connectionLost(None)
defer.returnValue(False)
else:
self.log.info(
"OnStart loading configuration default profile without credentials (auth. is not required)")
proto.dataReceived('load\r\n')
# Wait some more time till all configurations are loaded
pending_load = ['mtrouter', 'morouter', 'filter', 'group', 'smppcc', 'httpcc', 'user']
while True:
for _pl in pending_load:
if re.match(r'.*%s configuration loaded.*' % _pl, tr.value(), re.DOTALL):
self.log.info("%s configuration loaded.", _pl)
pending_load.remove(_pl)
if len(pending_load) > 0:
waitDeferred = defer.Deferred()
reactor.callLater(0.3, waitDeferred.callback, None)
yield waitDeferred
else:
break
proto.dataReceived('quit\r\n')
proto.connectionLost(None)
defer.returnValue(False)
示例2: doStart
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import doStart [as 别名]
def doStart(self):
debug( "Starting factory." )
ServerFactory.doStart(self)
示例3: doStart
# 需要导入模块: from twisted.internet.protocol import ServerFactory [as 别名]
# 或者: from twisted.internet.protocol.ServerFactory import doStart [as 别名]
def doStart(self):
self.wrappedFactory.doStart()
ServerFactory.doStart(self)