{ "info": { "author": "Anthony Rebello", "author_email": "rebello.anthony@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7" ], "description": "python-tee\n==========\n\n|Build Status| |PyPI version|\n\nPython library to tee stderr / stdout to a file\n\nInstallation\n------------\n\n.. code:: bash\n\n pip install tee\n\nQuick Start\n-----------\n\n``tee_test.py``\n\n.. code:: python\n\n import sys\n from tee import StdoutTee, StderrTee\n\n with StdoutTee(\"mystdout.txt\"), StderrTee(\"mystderr.txt\"):\n sys.stdout.write(\"[stdout] hello\\n\")\n sys.stderr.write(\"[stderr] hello\\n\")\n sys.stdout.write(\"[stdout] world\\n\")\n sys.stderr.write(\"[stderr] world\\n\")\n\n sys.stdout.write(\"[stdout] not going to be written to file\\n\")\n sys.stderr.write(\"[stderr] not going to be written to file\\n\")\n\n.. code:: bash\n\n $ python tee_test.py\n\n [stdout] hello\n [stderr] hello\n [stdout] world\n [stderr] world\n [stdout] not going to be written to file\n [stderr] not going to be written to file\n\n $ cat mystdout.txt \n [stdout] hello\n [stdout] world\n\n $ cat mystderr.txt \n [stderr] hello\n [stderr] world\n\nFilters\n-------\n\nStdoutTee and StderrTee take filters as parameters which run before\nwriting to a file or the stream. These filters are callables that take\nthe message to be written as input and return either None or a new\nmessage.\n\nI find them particularly useful when you want to write colorized output\nto the stream, but strip out the control characters when writing to a\nfile, especially when using fabric.\n\n.. code:: python\n\n import re\n import tee\n from fabric.api import run\n\n def _remove_control_chars(message):\n return re.sub(r'(\\x9B|\\x1B\\[)[0-?]*[ -\\/]*[@-~]', \"\", message)\n\n def echo_color():\n with tee.StdoutTee(\"fabout.txt\", mode=\"a\", file_filters=[_remove_control_chars]):\n run(\"\"\"echo -e \"\\E[1;32mHello World \\E[4;31mLets add some\\E[0m\\E[1;34m color\" && tput sgr0\"\"\")\n\n.. code:: bash\n\n fab -H localhost echo_color\n\n.. |Build Status| image:: https://travis-ci.org/algrebe/python-tee.svg?branch=master\n :target: https://travis-ci.org/algrebe/python-tee\n.. |PyPI version| image:: https://badge.fury.io/py/tee.svg\n :target: https://badge.fury.io/py/tee\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/algrebe/python-tee/tarball/0.0.3", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/algrebe/python-tee", "keywords": "tee", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "tee", "package_url": "https://pypi.org/project/tee/", "platform": "", "project_url": "https://pypi.org/project/tee/", "project_urls": { "Download": "https://github.com/algrebe/python-tee/tarball/0.0.3", "Homepage": "https://github.com/algrebe/python-tee" }, "release_url": "https://pypi.org/project/tee/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "Python library to tee stderr/stdout temporarily", "version": "0.0.3" }, "last_serial": 4091467, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "4eb4b88eb860918e04f7f39709f1a668", "sha256": "662c899282cafa8366f27c1d0e4fe5bc106c30784d536614b7e65d18ca1aa0b6" }, "downloads": -1, "filename": "tee-0.0.1-py2-none-any.whl", "has_sig": false, "md5_digest": "4eb4b88eb860918e04f7f39709f1a668", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 3133, "upload_time": "2017-04-11T15:04:05", "url": "https://files.pythonhosted.org/packages/e3/3f/23c68140477ad8c4aa7a194b066b7de458fe10cfb3ac02cb21847fc5e1e4/tee-0.0.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8a12e0b27f11c9e2c39aa251fb21da15", "sha256": "5ddcf1c35903f1d9b916672bf05f0fb7ef7b935679a8e641626e214f7a4f9215" }, "downloads": -1, "filename": "tee-0.0.1.tar.gz", "has_sig": false, "md5_digest": "8a12e0b27f11c9e2c39aa251fb21da15", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1899, "upload_time": "2017-04-11T15:04:07", "url": "https://files.pythonhosted.org/packages/b7/f8/483a3989803c2f9caf4670b052031e7e3b79836391b27616005d924aacee/tee-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "c3c6fd0156136333208905e4bacf95f1", "sha256": "b1751ae674ec56c401ea57d8f3802a2391b3e5e1c436d82398248bae094b40c2" }, "downloads": -1, "filename": "tee-0.0.2-py2-none-any.whl", "has_sig": false, "md5_digest": "c3c6fd0156136333208905e4bacf95f1", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 4702, "upload_time": "2017-04-11T19:23:32", "url": "https://files.pythonhosted.org/packages/85/88/4e0bb3efab74eac20bd6d66148439b0eb9951cd09bc8ffa6edebf9bb3b33/tee-0.0.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2d573c965bf2b5c73d7ef30b085577d4", "sha256": "d819969fe413fe3d65e1d4166ad5df85204d515bde87686fcc6bf713de3e1ab4" }, "downloads": -1, "filename": "tee-0.0.2.tar.gz", "has_sig": false, "md5_digest": "2d573c965bf2b5c73d7ef30b085577d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3115, "upload_time": "2017-04-11T19:23:34", "url": "https://files.pythonhosted.org/packages/78/d2/c29c47ab10ffd81ad475b6c41433b2b0f88d545ad0150f16c1ce34ae5237/tee-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "49846bfb5df141129ab3b4a817320885", "sha256": "16fdbb34b1e89a308094d86d2d497f5fa5ac47df9202f3dde913070d31699fad" }, "downloads": -1, "filename": "tee-0.0.3-py2-none-any.whl", "has_sig": false, "md5_digest": "49846bfb5df141129ab3b4a817320885", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 3078, "upload_time": "2018-07-23T02:14:52", "url": "https://files.pythonhosted.org/packages/ea/8d/3505b05e91bc2099fac84365bcd4581b7099c4c456051fed6b6377a751ba/tee-0.0.3-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a38cdfd0840510ee82c561bdceff0dfa", "sha256": "801dea18fe5046b57c26e87aa5c7ca0d1b8590cdc0e4e84158d07cdfa6628cdb" }, "downloads": -1, "filename": "tee-0.0.3.tar.gz", "has_sig": false, "md5_digest": "a38cdfd0840510ee82c561bdceff0dfa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3144, "upload_time": "2018-07-23T02:14:53", "url": "https://files.pythonhosted.org/packages/44/13/4daa2418b6c72de8255da00f873d709317accd57f38c6d8bf0233aeb9bf2/tee-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "49846bfb5df141129ab3b4a817320885", "sha256": "16fdbb34b1e89a308094d86d2d497f5fa5ac47df9202f3dde913070d31699fad" }, "downloads": -1, "filename": "tee-0.0.3-py2-none-any.whl", "has_sig": false, "md5_digest": "49846bfb5df141129ab3b4a817320885", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 3078, "upload_time": "2018-07-23T02:14:52", "url": "https://files.pythonhosted.org/packages/ea/8d/3505b05e91bc2099fac84365bcd4581b7099c4c456051fed6b6377a751ba/tee-0.0.3-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a38cdfd0840510ee82c561bdceff0dfa", "sha256": "801dea18fe5046b57c26e87aa5c7ca0d1b8590cdc0e4e84158d07cdfa6628cdb" }, "downloads": -1, "filename": "tee-0.0.3.tar.gz", "has_sig": false, "md5_digest": "a38cdfd0840510ee82c561bdceff0dfa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3144, "upload_time": "2018-07-23T02:14:53", "url": "https://files.pythonhosted.org/packages/44/13/4daa2418b6c72de8255da00f873d709317accd57f38c6d8bf0233aeb9bf2/tee-0.0.3.tar.gz" } ] }