METADATA 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. Metadata-Version: 2.0
  2. Name: delegator.py
  3. Version: 0.0.13
  4. Summary: Subprocesses for Humans 2.0.
  5. Home-page: https://github.com/kennethreitz/delegator
  6. Author: Kenneth Reitz
  7. Author-email: me@kennethreitz.com
  8. License: MIT
  9. Platform: UNKNOWN
  10. Classifier: Programming Language :: Python
  11. Classifier: Programming Language :: Python :: 2.6
  12. Classifier: Programming Language :: Python :: 2.7
  13. Classifier: Programming Language :: Python :: 3
  14. Classifier: Programming Language :: Python :: 3.3
  15. Classifier: Programming Language :: Python :: 3.4
  16. Classifier: Programming Language :: Python :: 3.5
  17. Classifier: Programming Language :: Python :: 3.6
  18. Classifier: Programming Language :: Python :: Implementation :: CPython
  19. Classifier: Programming Language :: Python :: Implementation :: PyPy
  20. Requires-Dist: pexpect (>=4.1.0)
  21. Delegator.py — Subprocesses for Humans 2.0
  22. =======================================
  23. .. image:: https://img.shields.io/pypi/v/delegator.py.svg
  24. :target: https://pypi.python.org/pypi/delegator.py
  25. .. image:: https://img.shields.io/pypi/l/delegator.py.svg
  26. :target: https://pypi.python.org/pypi/delegator.py
  27. .. image:: https://img.shields.io/pypi/wheel/delegator.py.svg
  28. :target: https://pypi.python.org/pypi/delegator.py
  29. .. image:: https://img.shields.io/pypi/pyversions/delegator.py.svg
  30. :target: https://pypi.python.org/pypi/delegator.py
  31. .. image:: https://img.shields.io/badge/SayThanks.io-☼-1EAEDB.svg
  32. :target: https://saythanks.io/to/kennethreitz
  33. **Delegator.py** is a simple library for dealing with subprocesses, inspired
  34. by both `envoy <https://github.com/kennethreitz/envoy>`_ and `pexpect <http://pexpect.readthedocs.io>`_ (in fact, it depends on it!).
  35. This module features two main functions ``delegator.run()`` and ``delegator.chain()``. One runs commands, blocking or non-blocking, and the other runs a chain of commands, separated by the standard unix pipe operator: ``|``.
  36. Basic Usage
  37. -----------
  38. Basic run functionality:
  39. .. code:: pycon
  40. >>> c = delegator.run('ls')
  41. >>> print c.out
  42. README.rst delegator.py
  43. >>> c = delegator.run('long-running-process', block=False)
  44. >>> c.pid
  45. 35199
  46. >>> c.block()
  47. >>> c.return_code
  48. 0
  49. Commands can be passed in as lists as well (e.g. ``['ls', '-lrt']``), for parameterization.
  50. Basic chain functionality:
  51. .. code:: pycon
  52. # Can also be called with ([['fortune'], ['cowsay']]).
  53. # or, delegator.run('fortune').pipe('cowsay')
  54. >>> c = delegator.chain('fortune | cowsay')
  55. >>> print c.out
  56. _______________________________________
  57. / Our swords shall play the orators for \
  58. | us. |
  59. | |
  60. \ -- Christopher Marlowe /
  61. ---------------------------------------
  62. \ ^__^
  63. \ (oo)\_______
  64. (__)\ )\/\
  65. ||----w |
  66. || ||
  67. Expect functionality is built-in too, on non-blocking commands:
  68. .. code:: pycon
  69. >>> c.expect('Password:')
  70. >>> c.send('PASSWORD')
  71. >>> c.block()
  72. Other functions:
  73. .. code:: pycon
  74. >>> c.kill()
  75. >>> c.send('SIGTERM', signal=True)
  76. # Only available when block=True, otherwise, use c.out.
  77. >>> c.err
  78. ''
  79. # Direct access to pipes.
  80. >>> c.std_err
  81. <open file '<fdopen>', mode 'rU' at 0x10a5351e0>
  82. Installation
  83. ------------
  84. ::
  85. $ pip install delegator.py
  86. ✨🍰✨