{ "info": { "author": "Terminal Labs", "author_email": "solutions@terminallabs.com", "bugtrack_url": null, "classifiers": [ "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Topic :: Utilities" ], "description": "# README\n\nThis project provides an entry point `cli-passthrough` in the terminal that accepts any amount of parameters, and runs those parameters as it's own command. Except in a few special cases, this will output to the terminal exactly what the command would have, including any formatting done with escape sequences. Both the combined stdout and stderr are logged, with order preserved, in `logs/history.log`, and the stderr by itself is logged in `/logs/stderr.log`. These log files are written to in realtime. The output to the terminal is also in realtime.\n\nThis project was motivated by making a wrapper on another application which needed to be used over the CLI. I wanted to also use the wrapper from the CLI as well. I wanted to see the output of the program I was invoking in real-time, in the same formatting, and log everything. In other words, I wanted the following:\n\n1. ANY COMMAND: Run nearly any command given to it.\n2. FLEXIBLE LOGGING: Capture stdout and stderr independently for flexible logging.\n3. ORDER PESERVATION: Preserve order of stdout and stderr\n4. REALTIME OUTPUT: Output to the screen in realtime, i.e. don't wait for the command to exit before dumping to the screen.\n5. EXIT STATUS: Capture exit code\n6. FORMATTING PRESERVED: Preserve ANSI escape sequences so most things are still formatted as if not run through this passthrough.\n\n\n| | 1 | 2 | 3 | 4 | 5 | 6 | note |\n|------------------------------|---|---|---|---|---|-----|------|\n| os.system | Y | N | Y | Y | Y | Y | Doesn't capture output at all |\n| os.popen | N | N | Y | N | N | Y | Deprecated & obsolete |\n| os.exec* | Y | N | - | N | N | N | Really not the intended use |\n| pexpect | Y | N | Y | Y | Y | Y | Bad logging |\n| subprocess.popen + threads | Y | Y | Y | N | Y | Y/N | Threads just enable separate logging, not realtime output |\n| subprocess.popen + pty | Y | Y | Y | Y | Y | Y | We got it! |\n\n\n## Known Limitations\n\nThis implementation of subprocess.popen + pty currently has the following limitations:\n\n1. It doesn't run *every* command, just most. `ssh` doesn't work :/\n\n1. It makes assumptions about the terminal size. It would be better if it detected the terminal the python is ran in, and use the same dimensions.\n\nThis is very much largely adapted (copied) from [this SO post](https://stackoverflow.com/a/31953436). I just wrapped it up into an importable function, gave it a CLI itself, and made basic logging to illustrate the point. Feel free to copy/paste/tweek it yourself.\n\n**If you find something better** please let me know! I'd be more than happy to upgrade or replace this. This is simply the best I've found so far.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/terminal-labs/cli-passthrough", "keywords": "cli utilities logging pty subprocess terminal", "license": "BSD-3-Clause", "maintainer": "", "maintainer_email": "", "name": "CLI-passthrough", "package_url": "https://pypi.org/project/CLI-passthrough/", "platform": "", "project_url": "https://pypi.org/project/CLI-passthrough/", "project_urls": { "Homepage": "https://github.com/terminal-labs/cli-passthrough" }, "release_url": "https://pypi.org/project/CLI-passthrough/0.1.2/", "requires_dist": [ "click" ], "requires_python": "", "summary": "Importable CLI-passthrough with bells and whistles.", "version": "0.1.2" }, "last_serial": 3848883, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "53f3eaef5e423a859e9f5356eba908e3", "sha256": "98bf5e8142049424cb08b654e4c0646b9e6bd50e1196f8a555ce54a54d3597a0" }, "downloads": -1, "filename": "CLI_passthrough-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "53f3eaef5e423a859e9f5356eba908e3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5039, "upload_time": "2018-05-09T19:45:44", "url": "https://files.pythonhosted.org/packages/ec/32/4109fd6e896172da80a7b2fccd8280c6f63c8aab689e685e51cb20f50f8c/CLI_passthrough-0.1-py3-none-any.whl" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "3763a9032086bbea90d740344bbcd90d", "sha256": "5c2ba6bcd70921068246c90bfb4c591070b1d0b919fc0cc6610271e0dc290ad2" }, "downloads": -1, "filename": "CLI_passthrough-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "3763a9032086bbea90d740344bbcd90d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5298, "upload_time": "2018-05-09T19:50:45", "url": "https://files.pythonhosted.org/packages/be/c2/d7b80c4a7d417b9ff441ff7fad6e5014fec3e690d8de1d287d6416a5d3df/CLI_passthrough-0.1.1-py3-none-any.whl" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "75fe400b205feb2534ec5566ec9c821a", "sha256": "006f15aad1c034bdb9b8bb0cbdb8e476de9fb96d39cc2f6e2606d768234ed180" }, "downloads": -1, "filename": "CLI_passthrough-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "75fe400b205feb2534ec5566ec9c821a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5211, "upload_time": "2018-05-09T21:44:48", "url": "https://files.pythonhosted.org/packages/b1/6b/ad79fcfb12983b584bd300f6b269c26fc5a7770107f13aeab0b987b2d76a/CLI_passthrough-0.1.2-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "75fe400b205feb2534ec5566ec9c821a", "sha256": "006f15aad1c034bdb9b8bb0cbdb8e476de9fb96d39cc2f6e2606d768234ed180" }, "downloads": -1, "filename": "CLI_passthrough-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "75fe400b205feb2534ec5566ec9c821a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5211, "upload_time": "2018-05-09T21:44:48", "url": "https://files.pythonhosted.org/packages/b1/6b/ad79fcfb12983b584bd300f6b269c26fc5a7770107f13aeab0b987b2d76a/CLI_passthrough-0.1.2-py3-none-any.whl" } ] }