deprecated.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # -*- coding: utf-8 -*-
  2. """
  3. some deprecated calls
  4. (c) 2008-2009, Holger Krekel and others
  5. """
  6. import execnet
  7. def PopenGateway(python=None):
  8. """instantiate a gateway to a subprocess
  9. started with the given 'python' executable.
  10. """
  11. APIWARN("1.0.0b4", "use makegateway('popen')")
  12. spec = execnet.XSpec("popen")
  13. spec.python = python
  14. return execnet.default_group.makegateway(spec)
  15. def SocketGateway(host, port):
  16. """This Gateway provides interaction with a remote process
  17. by connecting to a specified socket. On the remote
  18. side you need to manually start a small script
  19. (py/execnet/script/socketserver.py) that accepts
  20. SocketGateway connections or use the experimental
  21. new_remote() method on existing gateways.
  22. """
  23. APIWARN("1.0.0b4", "use makegateway('socket=host:port')")
  24. spec = execnet.XSpec("socket={}:{}".format(host, port))
  25. return execnet.default_group.makegateway(spec)
  26. def SshGateway(sshaddress, remotepython=None, ssh_config=None):
  27. """instantiate a remote ssh process with the
  28. given 'sshaddress' and remotepython version.
  29. you may specify an ssh_config file.
  30. """
  31. APIWARN("1.0.0b4", "use makegateway('ssh=host')")
  32. spec = execnet.XSpec("ssh=%s" % sshaddress)
  33. spec.python = remotepython
  34. spec.ssh_config = ssh_config
  35. return execnet.default_group.makegateway(spec)
  36. def APIWARN(version, msg, stacklevel=3):
  37. import warnings
  38. Warn = DeprecationWarning("(since version {}) {}".format(version, msg))
  39. warnings.warn(Warn, stacklevel=stacklevel)