{"id":13660391,"url":"https://github.com/haarcuba/pimped_subprocess","last_synced_at":"2025-08-31T13:37:46.375Z","repository":{"id":57452760,"uuid":"79399891","full_name":"haarcuba/pimped_subprocess","owner":"haarcuba","description":"a pimped-up wrapper around Python's subprocess module that can monitors the subprocess output line by line","archived":false,"fork":false,"pushed_at":"2019-03-05T23:25:05.000Z","size":29,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-28T13:31:27.641Z","etag":null,"topics":["death","monitor","subprocess"],"latest_commit_sha":null,"homepage":"https://haarcuba.github.io/pimped_subprocess/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haarcuba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-19T00:45:32.000Z","updated_at":"2021-11-21T05:18:38.000Z","dependencies_parsed_at":"2022-09-04T05:11:55.532Z","dependency_job_id":null,"html_url":"https://github.com/haarcuba/pimped_subprocess","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/haarcuba/pimped_subprocess","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haarcuba%2Fpimped_subprocess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haarcuba%2Fpimped_subprocess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haarcuba%2Fpimped_subprocess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haarcuba%2Fpimped_subprocess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haarcuba","download_url":"https://codeload.github.com/haarcuba/pimped_subprocess/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haarcuba%2Fpimped_subprocess/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272988780,"owners_count":25026959,"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","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["death","monitor","subprocess"],"created_at":"2024-08-02T05:01:21.048Z","updated_at":"2025-08-31T13:37:46.313Z","avatar_url":"https://github.com/haarcuba.png","language":"Python","readme":"# Pimped Subprocess\nThis is a library of \"pimped up\" subprocess modules with monitoring capabilities.\n\n## Installation\n\nSimple:\n\n    $ pip install pimped_subprocess\n\n## Pimped Subprocess\n\n`PimpedSubprocess` allows you to run subprocesses in a similar manner to Python's standard `subprocesses`, except that it allows you to follow the subprocess `stdout` stream line by line.\n\n```python\nimport pimped_subprocess\nimport time\n\nclass PrependLineNumber( object ):\n    def __init__( self ):\n        self._counter = 0\n\n    def __call__( self, line ):\n        self._counter += 1\n        print( '{:04}:\\t{}'.format( self._counter, line ) )\n\nprependLineNumber = PrependLineNumber()\np = pimped_subprocess.PimpedSubprocess( 'ls -l', shell = True )\n\n# must register to get the lines\np.onOutput( prependLineNumber )\n\n# acutally run the subprocess\np.launch()\n\n# wait for it to finish\np.process.wait()\ntime.sleep( 0.1 ) # wait a little extra to finish reading everything\n```\n\nThis code will produce something like this:\n\n    0001:   total 44\n    0002:   drwxrwxr-x 2 yoav yoav 4096 ינו 19 02:40 dist\n    0003:   drwxrwxr-x 2 yoav yoav 4096 ינו 19 02:52 examples\n    0004:   -rw-rw-r-- 1 yoav yoav  258 ינו 19 02:35 go.py\n    0005:   drwxrwxr-x 2 yoav yoav 4096 ינו 19 02:39 pimped_subprocess\n    0006:   drwxrwxr-x 2 yoav yoav 4096 ינו 18 23:58 pimped_subprocess.egg-info\n    0007:   drwxrwxr-x 7 yoav yoav 4096 ינו 19 00:38 python2\n    0008:   -rw-rw-r-- 1 yoav yoav  230 ינו 19 01:28 Rakefile\n    0009:   -rw-rw-r-- 1 yoav yoav  922 ינו 19 02:54 README.md\n    0010:   -rw-rw-r-- 1 yoav yoav  700 ינו 19 02:40 setup.py\n    0011:   drwxrwxr-x 4 yoav yoav 4096 ינו 19 02:34 test\n    0012:   drwxrwxr-x 2 yoav yoav 4096 ינו 19 01:41 tools\n\n\n## Multiple Output Monitors\n\nYou can register multiple output monitors by calling `onOutput` multiple times:\n\n```python\np.onOutput( callable1 )\np.onOutput( callable2 )\np.onOutput( callable3 )\n```\n\n## Process End Event\n\nYou can also register to get notified when the process ends:\n\n```python\n\ndef myCallback( token, exitCode ):\n    print( 'process ended with exit code: {}'.format( exitCode ) )\n\np.onProcessEnd( myCallback, 'some token here' )\n```\n\nWhen the process ends, `myCallback` will be called with the token and the process's exit code.\nThe token's job is to help you distinguish between different processes that use the same callback.\n\n## Remote Processes\n\nCheck out the [Closer](https://github.com/haarcuba/closer) library for using `PimpedSubprocess` capabilites on remote (via SSH) processes.\n\n## Running the Tests\n\nIf you want to run the tests you will need  `testix` and `pytest`:\n\n    $ pip install testix pytest\n\nYou'll also need `rake`, but at least on recent Ubuntu versions - rake is installed by default.\n\nOnce you have all these, from the root of the source tree:\n\n    $ rake test\n\nyou can see what indivitual test suites exist with\n\n    $ rake -T\n    found 3 test files\n    rake test                              # run all tests\n    rake test/test_pimped_subprocess.py    # run tests in test/test_pimped_subprocess.py\n    rake test/test_real_live_processes.py  # run tests in test/test_real_live_processes.py\n    rake test/test_remote.py               # run tests in test/test_remote.py\n\n## Encodings\n\nThe `launch()` function takes an encoding argument, e.g.\n\n    \n```python\n    p.launch( encoding = 'utf-8' )\n```\n\nBy default it uses the `latin-1` encoding, since this encoding never produces\ndecoding errors, but you can change it if you like.\n\n## Windows Support\n\nThis library leans on the `pty` module which seems to be unavailable for Windows. Hence, this is a Unix only library, sorry.\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaarcuba%2Fpimped_subprocess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaarcuba%2Fpimped_subprocess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaarcuba%2Fpimped_subprocess/lists"}