当前位置: 首页>>代码示例>>Python>>正文


Python ServerFactory.doStart方法代码示例

本文整理汇总了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)
开发者ID:AVert,项目名称:jasmin,代码行数:59,代码来源:factory.py

示例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)
开发者ID:cahirwpz,项目名称:tpserver-py,代码行数:5,代码来源:server.py

示例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)
开发者ID:BillTheBest,项目名称:xmppserver,代码行数:5,代码来源:compression.py


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