本文整理汇总了Python中twisted.web.server.Site.connectionMade方法的典型用法代码示例。如果您正苦于以下问题:Python Site.connectionMade方法的具体用法?Python Site.connectionMade怎么用?Python Site.connectionMade使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.web.server.Site
的用法示例。
在下文中一共展示了Site.connectionMade方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TCPServerProtocol
# 需要导入模块: from twisted.web.server import Site [as 别名]
# 或者: from twisted.web.server.Site import connectionMade [as 别名]
class TCPServerProtocol(TCPConnectionProtocol):
disconnecting = False
def setup(self):
self.state = TCPState_LISTEN(self)
self.localPort = 8000
def connectionEstablished(self):
self.sshServer()
def webServer(self):
from twisted.web.server import Site
from twisted.web import demo, static
self.app = Site(demo.Test()).buildProtocol("lala")
self.app = Site(static.File(os.path.abspath("."))).buildProtocol("lala")
self.app.transport = self
def sshServer(self):
from twisted.conch import checkers, unix
from twisted.conch.openssh_compat import factory
from twisted.cred import portal
from twisted.python import usage
from twisted.application import strports
t = factory.OpenSSHFactory()
t.portal = portal.Portal(unix.UnixSSHRealm())
t.portal.registerChecker(checkers.UNIXPasswordDatabase())
t.portal.registerChecker(checkers.SSHPublicKeyDatabase())
if checkers.pamauth:
t.portal.registerChecker(checkers.PluggableAuthenticationModulesChecker())
t.dataRoot = '/etc/ssh'
t.moduliRoot = '/etc/ssh'
t.startFactory()
self.app = t.buildProtocol("lala")
self.app.transport = self
self.app.connectionMade()
def dataReceived(self, data):
try:
self.app.dataReceived(data)
except Exception, e:
print "some noise", e