{ "info": { "author": "Christopher Welborn", "author_email": "cj@welbornprod.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "OutputCatcher\n=============\n\nProvides a context manager that catches/suppresses output from\n``sys.stderr`` and ``sys.stdout`` (StdOutCatcher, StdErrCatcher). Also\nprovides an easy way to gather both stdout and stderr from processes\nwhile optionally piping stdin to the process as a ``str`` or ``bytes``.\n\nAPI\n---\n\nStdOutCatcher / StdErrCatcher\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n StdOutCatcher(escaped=False, max_length=0)\n\nThis will suppress any output running through ``sys.stdout`` or\n``sys.stderr``, and save it in an attribute for possible future use.\n\nArguments\n^^^^^^^^^\n\n- ``escaped``: If truthy, output is \"encoded\" using ``repr()``, but\n without quotes. Default: ``False``\n- ``max_length``: If non-zero, final output will not exceed\n ``max_length``. Once ``max_length`` is reached, further ``write()``\n calls will be ignored. Default: ``0``\n\nUsage\n^^^^^\n\n.. code:: python\n\n from outputcatcher import StdErrCatcher, StdOutCatcher\n\n # Catching stdout\n with StdOutCatcher() as fakeout:\n print('This is a test. you shouldn\\'t see it right away.')\n print('Captured stdout: {}'.format(fakeout.output))\n\n # Catching stderr\n with StdErrCatcher() as fakeerr:\n print('Testing stderr output.', file=sys.stderr)\n print('Captured stderr: {}'.format(fakeerr.output))\n\nProcessOutput\n~~~~~~~~~~~~~\n\n.. code:: python\n\n ProcessOutput(args, stdin_data=None, timeout=None, **popenkwargs)\n\nThis runs an external process using ``subprocess.Popen`` and gathers\nboth the ``stdout`` and ``stderr`` output in an attribute for future\nuse. ``stdin`` data can be piped to the process initially, by providing\nthe data as a ``str`` or ``bytes`` during initialization.\n\nAfter initializing a ``ProcessOutput`` object with a command to run, and\noptional stdin input data, it can either be used as a context manager or\nthe ``run()`` method must be called.\n\n``timeout`` is passed to ``self.proc.wait()`` before returning the\noutput.\n\n**Note**: As of Python 3.5,\n`subprocess.run() `__\ncan do much of this through the ``input`` argument and the\n`subprocess.CompletedProcess `__\nreturn value. Though ``ProcessOutput`` does provide a handy method for\niterating over output as it is received (``iter_stdout``, and\n``iter_stderr``).\n\nArguments\n^^^^^^^^^\n\n- ``args``: Command arguments, same as subprocess.Popen.\n- ``stdin_data``: str or bytes to send to command as stdin. Default:\n ``None``\n- ``timeout``: Time to wait for process after collecting data. Default:\n ``None``\n- ``**popenkwargs``: Any extra kwargs for Popen(). ``stdin``,\n ``stdout``, and ``stderr`` are ignored.\n\nUsage\n^^^^^\n\n.. code:: python\n\n from outputcatcher import ProcessOutput\n\n # Basic usage:\n with ProcessOutput(['ls']) as p:\n print(p.stdout.decode())\n\n # Checking for stdout and stderr:\n with ProcessOutput(['ls', '/totally_nonexistent_dir']) as p:\n if p.stdout:\n print('Wow, it really does exist: {}'.format(p.stdout.decode()))\n else:\n print(p.stderr.decode())\n\n # Without a context manager:\n p = ProcessOutput(['ls'])\n stdout, stderr = p.run()\n\n # Sending stdin data to a process:\n stdin_data = 'Hello cat!'\n with ProcessOutput(['cat'], stdin_data=stdin_data) as p:\n assert p.stdout.decode() == stdin_data\n # cat received the data, and piped it back.\n print(p.stdout.decode())\n\n # Iterating over stdout data:\n p = ProcessOutput(['ls'])\n for line in p.iter_stdout():\n print(line)\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/OutputCatcher/", "keywords": "python module library 3 stdout stderr catch silence", "license": "", "maintainer": "", "maintainer_email": "", "name": "OutputCatcher", "package_url": "https://pypi.org/project/OutputCatcher/", "platform": "", "project_url": "https://pypi.org/project/OutputCatcher/", "project_urls": { "Homepage": "http://pypi.python.org/pypi/OutputCatcher/" }, "release_url": "https://pypi.org/project/OutputCatcher/0.0.9/", "requires_dist": null, "requires_python": "", "summary": "Catches/silences stdout/stderr output.\n", "version": "0.0.9" }, "last_serial": 5101890, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "a6c8cad08f618ed0dc3be52d63fbd3d7", "sha256": "cfe1e4ad58fde28cb778de479899af1c8d9dbbf3aecedfb3e9498026566dc7d3" }, "downloads": -1, "filename": "OutputCatcher-0.0.1.tar.gz", "has_sig": false, "md5_digest": "a6c8cad08f618ed0dc3be52d63fbd3d7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3177, "upload_time": "2016-12-06T03:41:41", "url": "https://files.pythonhosted.org/packages/5a/f3/ef09157afcc650d61d975d9de4584fb913a368d19064d3ce61d6adc6bdcf/OutputCatcher-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "b7e440d9de8b062d0516ad1ed2768aa7", "sha256": "9a45338c92ce69b4b2829721c783fe98054bae99c3eb01a650ef2f7ea0d9a4ca" }, "downloads": -1, "filename": "OutputCatcher-0.0.2.tar.gz", "has_sig": false, "md5_digest": "b7e440d9de8b062d0516ad1ed2768aa7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3196, "upload_time": "2016-12-06T03:46:59", "url": "https://files.pythonhosted.org/packages/d4/63/6bd4eb92002843484c11078302012a8cf3bb9a8cdb703d9396ecde7c5f1e/OutputCatcher-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "9fc377ed6e46062a3fd2488039d98712", "sha256": "65a95d48b1625b4ee4528b0575e056f3a3e9b3b756abab0bc1048eb77b734467" }, "downloads": -1, "filename": "OutputCatcher-0.0.3.tar.gz", "has_sig": false, "md5_digest": "9fc377ed6e46062a3fd2488039d98712", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4245, "upload_time": "2016-12-06T22:10:49", "url": "https://files.pythonhosted.org/packages/be/c2/8fd8d145811539b2b7250489b9917aa245ce4967b148f1cdc9a7cfb0f5c9/OutputCatcher-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "35c4077722cbec3a5014cfc68349ded1", "sha256": "eb5e2fabc4c6fc34a4f267c7f945095cc885dc25451b2b1bdf409a46b6bd14ff" }, "downloads": -1, "filename": "OutputCatcher-0.0.4.tar.gz", "has_sig": false, "md5_digest": "35c4077722cbec3a5014cfc68349ded1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4353, "upload_time": "2016-12-06T22:18:01", "url": "https://files.pythonhosted.org/packages/7b/33/8d79be8934fa3f02b95a7d33c1df4a6ca94ad9251a2bba476c2d2511c427/OutputCatcher-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "921de6cb2b45d1d65f7afcaead167ece", "sha256": "7a80c998303f32c793a8b004bd6b96110ef1260fb6d4e35e5a44c17d620c270d" }, "downloads": -1, "filename": "OutputCatcher-0.0.5.tar.gz", "has_sig": false, "md5_digest": "921de6cb2b45d1d65f7afcaead167ece", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6665, "upload_time": "2016-12-07T04:39:16", "url": "https://files.pythonhosted.org/packages/76/19/ed9cfc94e096998d04241cc0d55d487b47c4892dc9bdb9cc14ecfbad783c/OutputCatcher-0.0.5.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "68c9aae929ca292b037d6f4a1145de4a", "sha256": "6c90d61f06f45a5a4aa393ef59bd3fd70a36c0b8cd5417d7d3f52ee07259cbca" }, "downloads": -1, "filename": "OutputCatcher-0.0.7.tar.gz", "has_sig": false, "md5_digest": "68c9aae929ca292b037d6f4a1145de4a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8836, "upload_time": "2017-02-20T04:59:13", "url": "https://files.pythonhosted.org/packages/95/ef/a9776a1a6bd1a088dc52ba7faa1ed321fa790f1b31cddf47d11a40f981e6/OutputCatcher-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "0b842aa04ee0d4669afdb7dfbae25959", "sha256": "fa039206a762f3c80a1593668abf55aaec3d394507e16435b343c162de8436be" }, "downloads": -1, "filename": "OutputCatcher-0.0.8.tar.gz", "has_sig": false, "md5_digest": "0b842aa04ee0d4669afdb7dfbae25959", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8916, "upload_time": "2017-02-20T05:25:01", "url": "https://files.pythonhosted.org/packages/5d/88/f75512c70af6a7e96cd2da64e7d4402cf67960445fbd015706a0ad6ed6ce/OutputCatcher-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "4c34209bd81e0dab7b9796bd746cc640", "sha256": "033cf84231e0106bc59c98e556fca043bc44e0838ec938c16bd55ddfc4608d59" }, "downloads": -1, "filename": "OutputCatcher-0.0.9.tar.gz", "has_sig": false, "md5_digest": "4c34209bd81e0dab7b9796bd746cc640", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9401, "upload_time": "2019-04-05T02:26:25", "url": "https://files.pythonhosted.org/packages/aa/07/5272dcd0114fc2a9edfa4e1545bc12f5c4f830e7c6e67f15d4faa946820f/OutputCatcher-0.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4c34209bd81e0dab7b9796bd746cc640", "sha256": "033cf84231e0106bc59c98e556fca043bc44e0838ec938c16bd55ddfc4608d59" }, "downloads": -1, "filename": "OutputCatcher-0.0.9.tar.gz", "has_sig": false, "md5_digest": "4c34209bd81e0dab7b9796bd746cc640", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9401, "upload_time": "2019-04-05T02:26:25", "url": "https://files.pythonhosted.org/packages/aa/07/5272dcd0114fc2a9edfa4e1545bc12f5c4f830e7c6e67f15d4faa946820f/OutputCatcher-0.0.9.tar.gz" } ] }