deprecated.py 1.5 KB

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