{ "info": { "author": "anatoly techtonik", "author_email": "techtonik@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: System :: Shells" ], "description": "Running commands through a system shell\r\n---------------------------------------\r\n\r\nLook at `envoy`_ first. ``envoy.run(command)`` waits for completion\r\nbefore returning output, which is not what you need when wrapping long\r\nrunning tools, where output needed as soon as it appears,\r\n``shellrun.run(command)`` does not intercept output - there is a\r\nseparate command for that.\r\n\r\n::\r\n\r\n >>> import shellrun\r\n >>> r = shellrun.run('uptime')\r\n 04:06:37 up 2 min, 1 user, load average: 0.20, 0.19, 0.08\r\n >>> r.output\r\n >>> r.success\r\n True\r\n >>> r.retcode\r\n 0\r\n\r\nTo capture output\r\n`envoy `__-style, use\r\n``run_capture``. ``stdout`` and ``stderr`` are merged, because that\u2019s\r\nhow users see it:\r\n\r\n::\r\n\r\n >>> r = shellrun.run_capture('uptime')\r\n >>> r.output\r\n ' 04:07:16 up 2 min, 1 user, load average: 0.11, 0.17, 0.08\\n'\r\n >>> r.success\r\n True\r\n >>> r.retcode\r\n 0\r\n\r\nQuick comparison of result objects:\r\n\r\n+------------------+-------------------+\r\n| envoy.Response | shellrun.Result |\r\n+==================+===================+\r\n| .command | .command |\r\n+------------------+-------------------+\r\n| .status\\_code | .retcode |\r\n+------------------+-------------------+\r\n| | .success |\r\n+------------------+-------------------+\r\n| | .output |\r\n+------------------+-------------------+\r\n| .std\\_out | |\r\n+------------------+-------------------+\r\n| .std\\_err | |\r\n+------------------+-------------------+\r\n\r\nExample of ``.success`` usage:\r\n\r\n::\r\n\r\n from shellrun import run_capture\r\n\r\n r = run_capture('ls -la')\r\n if r.success:\r\n print(r.output)\r\n else:\r\n print(\"Error: '%s' exit code %s\" % (r.command, r.retcode))\r\n print(\" ...\")\r\n # print last three lines of output\r\n for line in r.output.splitlines()[-3:]:\r\n print(\" %s\" % line)\r\n\r\n.. _envoy: https://github.com/kennethreitz/envoy#envoy-python-subprocesses-for-humans", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/techtonik/shellrun", "keywords": "", "license": "Public Domain", "maintainer": "", "maintainer_email": "", "name": "shellrun", "package_url": "https://pypi.org/project/shellrun/", "platform": "", "project_url": "https://pypi.org/project/shellrun/", "project_urls": { "Homepage": "https://bitbucket.org/techtonik/shellrun" }, "release_url": "https://pypi.org/project/shellrun/3.1/", "requires_dist": null, "requires_python": null, "summary": "running commands through a system shell", "version": "3.1" }, "last_serial": 2026435, "releases": { "3.1": [ { "comment_text": "", "digests": { "md5": "4503feb20f74925d6912e95611783bb7", "sha256": "b05503518f2d3d07d605a4be094b48ad9fbbaa5ff8263255b946f9624e2d5c47" }, "downloads": -1, "filename": "shellrun-3.1.zip", "has_sig": false, "md5_digest": "4503feb20f74925d6912e95611783bb7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3891, "upload_time": "2014-10-12T17:42:24", "url": "https://files.pythonhosted.org/packages/91/79/716905a6f94044a4ef5a4c1a894d83edeed1250edd693997e1296b0e38b9/shellrun-3.1.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4503feb20f74925d6912e95611783bb7", "sha256": "b05503518f2d3d07d605a4be094b48ad9fbbaa5ff8263255b946f9624e2d5c47" }, "downloads": -1, "filename": "shellrun-3.1.zip", "has_sig": false, "md5_digest": "4503feb20f74925d6912e95611783bb7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3891, "upload_time": "2014-10-12T17:42:24", "url": "https://files.pythonhosted.org/packages/91/79/716905a6f94044a4ef5a4c1a894d83edeed1250edd693997e1296b0e38b9/shellrun-3.1.zip" } ] }