{"id":13827352,"url":"https://github.com/zackees/capturing_process","last_synced_at":"2025-04-12T23:42:38.651Z","repository":{"id":62560848,"uuid":"365298178","full_name":"zackees/capturing_process","owner":"zackees","description":"A subprocess type that streams out stdout/stderr easily","archived":false,"fork":false,"pushed_at":"2025-03-16T02:10:25.000Z","size":37,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T23:42:31.329Z","etag":null,"topics":["python","stderr","stdout","subprocess"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zackees.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-07T16:50:02.000Z","updated_at":"2025-03-16T02:10:28.000Z","dependencies_parsed_at":"2024-08-04T09:06:40.538Z","dependency_job_id":null,"html_url":"https://github.com/zackees/capturing_process","commit_stats":{"total_commits":24,"total_committers":2,"mean_commits":12.0,"dds":0.5,"last_synced_commit":"f1a62f820991e8e40f71fdd639008b72cb921578"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackees%2Fcapturing_process","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackees%2Fcapturing_process/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackees%2Fcapturing_process/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackees%2Fcapturing_process/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zackees","download_url":"https://codeload.github.com/zackees/capturing_process/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647255,"owners_count":21139081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","stderr","stdout","subprocess"],"created_at":"2024-08-04T09:01:54.484Z","updated_at":"2025-04-12T23:42:38.632Z","avatar_url":"https://github.com/zackees.png","language":"Python","readme":"# Finally, a subprocess type that streams out stdout/stderr easily\n\n[![Win_Tests](https://github.com/zackees/capturing_process/actions/workflows/push_win.yml/badge.svg)](https://github.com/zackees/capturing_process/actions/workflows/push_win.yml)\n[![Ubuntu_Tests](https://github.com/zackees/capturing_process/actions/workflows/push_ubuntu.yml/badge.svg)](https://github.com/zackees/capturing_process/actions/workflows/push_ubuntu.yml)\n[![MacOS_Tests](https://github.com/zackees/capturing_process/actions/workflows/push_macos.yml/badge.svg)](https://github.com/zackees/capturing_process/actions/workflows/push_macos.yml)\n\nCapturing the stderr AND stdout from a process in python is not that easy.\nThis class makes this capturing much easier by delegating the line capturing\nto seperate threads. This capture can be totally in memory or can optionally\nbe streamed to a output stream such as a file handle.\n\nThis class will unconditionally launch a shell command and the input will always\nbe string, not an array like what is accepted by subprocess.Popen().\n\n# Example:\n\nSuper simple example:\n\n```python\nfrom capturing_process import CapturingProcess\n\nout_stream = StringIO()\np = CapturingProcess(\"echo hi\", stdout=out_stream)\np.wait()\nself.assertIn(\"hi\", out_stream.getvalue())\nself.assertIn(\"hi\", p.get_stdout())\n```\n\nFor splitting the output to stdout and a file you'd write a stream class like so:\n\n```python\nimport logging\nclass MyStream:\n    def __init__(self) -\u003e None:\n        pass\n\n    def write(self, data: str) -\u003e None:\n        logging.info(data.rstrip('\\n'))\n        print(data, end=\"\")\n\n\nout_stream = MyStream()\nproc = CapturingProcess(\"echo hi\", stdout=out_stream)\nproc.wait()  # Output will be captured in logging file and stdout\n```\n\n\nTo silence an output stream (stdout/stderr) drop a StringIO object as an argument to\nthe CapturingProcess like so:\n\n\n## If you want the entire stdout/stderr bytes\n\n```python\nproc.get_stdout()\nproc.get_stderr()\n```\n\n# Python version: 3.6+\n\nBecause of the use of type annotations, this library is not compatible with python 2.7\nHowever you are free to strip out these type annotations and this project *should* work\npretty well.\n\n# Links:\n\n   * https://pypi.org/project/capturing-process/\n   * https://github.com/zackees/capturing_process\n\n\n# Versions\n\n  * 1.0.9: stdout/stderr threads are now forcefully killed within .1 second if they don't join.\n  * 1.0.8: Fixes CapturingProcess.kill blocking if the stdout and stderr threads fail to join.\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzackees%2Fcapturing_process","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzackees%2Fcapturing_process","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzackees%2Fcapturing_process/lists"}