本文整理汇总了Python中twisted.conch.ssh.connection.SSHConnection方法的典型用法代码示例。如果您正苦于以下问题:Python connection.SSHConnection方法的具体用法?Python connection.SSHConnection怎么用?Python connection.SSHConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.conch.ssh.connection
的用法示例。
在下文中一共展示了connection.SSHConnection方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cleanupConnectionImmediately
# 需要导入模块: from twisted.conch.ssh import connection [as 别名]
# 或者: from twisted.conch.ssh.connection import SSHConnection [as 别名]
def test_cleanupConnectionImmediately(self):
"""
L{_NewConnectionHelper.cleanupConnection} closes the transport with
C{abortConnection} if called with C{immediate} set to C{True}.
"""
class Abortable:
aborted = False
def abortConnection(self):
"""
Abort the connection.
"""
self.aborted = True
helper = _NewConnectionHelper(
None, None, None, None, None, None, None, None, None, None)
connection = SSHConnection()
connection.transport = SSHClientTransport()
connection.transport.transport = Abortable()
helper.cleanupConnection(connection, True)
self.assertTrue(connection.transport.transport.aborted)
示例2: doConnect
# 需要导入模块: from twisted.conch.ssh import connection [as 别名]
# 或者: from twisted.conch.ssh.connection import SSHConnection [as 别名]
def doConnect(options):
# log.deferr = handleError # HACK
if '@' in options['host']:
options['user'], options['host'] = options['host'].split('@',1)
host = options['host']
if not options['user']:
options['user'] = getpass.getuser()
if not options['port']:
options['port'] = 22
else:
options['port'] = int(options['port'])
host = options['host']
port = options['port']
conn = SSHConnection()
conn.options = options
vhk = default.verifyHostKey
uao = default.SSHUserAuthClient(options['user'], options, conn)
connect.connect(host, port, options, vhk, uao).addErrback(_ebExit)
示例3: doConnect
# 需要导入模块: from twisted.conch.ssh import connection [as 别名]
# 或者: from twisted.conch.ssh.connection import SSHConnection [as 别名]
def doConnect():
# log.deferr = handleError # HACK
if '@' in options['host']:
options['user'], options['host'] = options['host'].split('@',1)
if not options.identitys:
options.identitys = ['~/.ssh/id_rsa', '~/.ssh/id_dsa']
host = options['host']
if not options['user']:
options['user'] = getpass.getuser()
if not options['port']:
options['port'] = 22
else:
options['port'] = int(options['port'])
host = options['host']
port = options['port']
vhk = default.verifyHostKey
uao = default.SSHUserAuthClient(options['user'], options, SSHConnection())
connect.connect(host, port, options, vhk, uao).addErrback(_ebExit)
示例4: buildProtocol
# 需要导入模块: from twisted.conch.ssh import connection [as 别名]
# 或者: from twisted.conch.ssh.connection import SSHConnection [as 别名]
def buildProtocol(self, addr):
# here comes the EVIL
obj = self.userAuthObject.instance
bases = []
for base in obj.__class__.__bases__:
if base == connection.SSHConnection:
bases.append(SSHUnixClientProtocol)
else:
bases.append(base)
newClass = types.ClassType(obj.__class__.__name__, tuple(bases), obj.__class__.__dict__)
obj.__class__ = newClass
SSHUnixClientProtocol.__init__(obj)
log.msg('returning %s' % obj)
if self.d:
d = self.d
self.d = None
d.callback(None)
return obj
示例5: doConnect
# 需要导入模块: from twisted.conch.ssh import connection [as 别名]
# 或者: from twisted.conch.ssh.connection import SSHConnection [as 别名]
def doConnect(options):
# log.deferr = handleError # HACK
if '@' in options['host']:
options['user'], options['host'] = options['host'].split('@',1)
host = options['host']
if not options['user']:
options['user'] = getpass.getuser()
if not options['port']:
options['port'] = 22
else:
options['port'] = int(options['port'])
host = options['host']
port = options['port']
conn = SSHConnection()
conn.options = options
vhk = default.verifyHostKey
uao = default.SSHUserAuthClient(options['user'], options, conn)
connect.connect(host, port, options, vhk, uao).addErrback(_ebExit)
示例6: doConnect
# 需要导入模块: from twisted.conch.ssh import connection [as 别名]
# 或者: from twisted.conch.ssh.connection import SSHConnection [as 别名]
def doConnect():
# log.deferr = handleError # HACK
if '@' in options['host']:
options['user'], options['host'] = options['host'].split('@',1)
if not options.identitys:
options.identitys = ['~/.ssh/id_rsa', '~/.ssh/id_dsa']
host = options['host']
if not options['user']:
options['user'] = getpass.getuser()
if not options['port']:
options['port'] = 22
else:
options['port'] = int(options['port'])
host = options['host']
port = options['port']
vhk = default.verifyHostKey
uao = default.SSHUserAuthClient(options['user'], options, SSHConnection())
connect.connect(host, port, options, vhk, uao).addErrback(_ebExit)
示例7: __init__
# 需要导入模块: from twisted.conch.ssh import connection [as 别名]
# 或者: from twisted.conch.ssh.connection import SSHConnection [as 别名]
def __init__(self, channelFactory):
connection.SSHConnection.__init__(self)
self._channelFactory = channelFactory
示例8: test_cleanupConnectionNotImmediately
# 需要导入模块: from twisted.conch.ssh import connection [as 别名]
# 或者: from twisted.conch.ssh.connection import SSHConnection [as 别名]
def test_cleanupConnectionNotImmediately(self):
"""
L{_NewConnectionHelper.cleanupConnection} closes the transport cleanly
if called with C{immediate} set to C{False}.
"""
helper = _NewConnectionHelper(
None, None, None, None, None, None, None, None, None, None)
connection = SSHConnection()
connection.transport = StringTransport()
helper.cleanupConnection(connection, False)
self.assertTrue(connection.transport.disconnecting)
示例9: buildServerConnection
# 需要导入模块: from twisted.conch.ssh import connection [as 别名]
# 或者: from twisted.conch.ssh.connection import SSHConnection [as 别名]
def buildServerConnection(self):
# make a server connection
conn = connection.SSHConnection()
# server connections have a 'self.transport.avatar'.
class DummyTransport:
def __init__(self):
self.transport = self
def sendPacket(self, kind, data):
pass
def logPrefix(self):
return 'dummy transport'
conn.transport = DummyTransport()
conn.transport.avatar = self.avatar
return conn
示例10: serviceStarted
# 需要导入模块: from twisted.conch.ssh import connection [as 别名]
# 或者: from twisted.conch.ssh.connection import SSHConnection [as 别名]
def serviceStarted(self):
global conn
conn = self
self.localForwards = []
self.remoteForwards = {}
if not isinstance(self, connection.SSHConnection):
# make these fall through
del self.__class__.requestRemoteForwarding
del self.__class__.cancelRemoteForwarding
onConnect()
示例11: connectionSecure
# 需要导入模块: from twisted.conch.ssh import connection [as 别名]
# 或者: from twisted.conch.ssh.connection import SSHConnection [as 别名]
def connectionSecure(self):
if options['user']:
user = options['user']
else:
user = getpass.getuser()
self.requestService(SSHUserAuthClient(user, SSHConnection()))
示例12: __init__
# 需要导入模块: from twisted.conch.ssh import connection [as 别名]
# 或者: from twisted.conch.ssh.connection import SSHConnection [as 别名]
def __init__(self, completed):
connection.SSHConnection.__init__(self)
self._completed = completed
示例13: __init__
# 需要导入模块: from twisted.conch.ssh import connection [as 别名]
# 或者: from twisted.conch.ssh.connection import SSHConnection [as 别名]
def __init__(self, protocolFactory, protocolArgs, protocolKwArgs, width, height, *a, **kw):
connection.SSHConnection.__init__(self, *a, **kw)
self.protocolFactory = protocolFactory
self.protocolArgs = protocolArgs
self.protocolKwArgs = protocolKwArgs
self.width = width
self.height = height
示例14: __init__
# 需要导入模块: from twisted.conch.ssh import connection [as 别名]
# 或者: from twisted.conch.ssh.connection import SSHConnection [as 别名]
def __init__(self, p, exe=None, cmds=None):
connection.SSHConnection.__init__(self)
if p:
self.spawn = (p, exe, cmds)
else:
self.spawn = None
self.connected = 0
self.remoteForwards = {}