connect.py 672 B

123456789101112131415161718192021
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. #
  4. from twisted.conch.client import direct
  5. connectTypes = {"direct" : direct.connect}
  6. def connect(host, port, options, verifyHostKey, userAuthObject):
  7. useConnects = ['direct']
  8. return _ebConnect(None, useConnects, host, port, options, verifyHostKey,
  9. userAuthObject)
  10. def _ebConnect(f, useConnects, host, port, options, vhk, uao):
  11. if not useConnects:
  12. return f
  13. connectType = useConnects.pop(0)
  14. f = connectTypes[connectType]
  15. d = f(host, port, options, vhk, uao)
  16. d.addErrback(_ebConnect, useConnects, host, port, options, vhk, uao)
  17. return d