{ "info": { "author": "Yves-Gwenael Bourhis", "author_email": "ygbourhis at gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Author : Yves-Gwenael Bourhis\n\n ==================================================\n Wrap a shell comand into a python threaded object.\n ==================================================\n\n Usage:\n ======\n\n You want to launch the following bash commands in a thread::\n\n [user@localhost ~]$ ls -l | grep pdf | wc -l\n 5\n\n here is how you can do it::\n\n >>> Ls = WrapCommand( 'ls -l')\n >>> GrepPdf = WrapCommand( 'grep pdf')\n >>> Wc = WrapCommand( 'wc -l')\n >>> Wc.stdin = GrepPdf\n >>> GrepPdf.stdin = Ls\n >>> Wc.start( )\n >>> #Do stuff\n ...\n >>> Wc.join()\n >>> Wc.results\n ('5\\n', '')\n\n the 'results' property is a tuple (stdoutdata, stderrdata)\n\n You can also do it this way::\n\n >>> Ls = WrapCommand( 'ls -l | grep pdf | wc -l', shell=True)\n >>> Ls.start()\n >>> #Do stuff\n >>> Ls.join()\n >>> Ls.results[0]\n '5\\n'\n\n You would need to specify 'shell=True' when the command\n you wish to execute is actually built into the shell.\n i.e.: on Windows if you use built in commands such as 'dir' or 'copy':\n http://docs.python.org/library/subprocess.html#subprocess.Popen\n\n The purpose of doing it in a thread is when the above commands may\n take a few hours, and that you want to perform other tasks in the\n meanwhile.\n You can check the process is still running with::\n\n >>> Wc.is_alive( )\n False\n\n 'True' would be returned if still running.\n To terminate it prematurely (i.e. it deadlocked) you have the\n 'terminate()', 'kill()' or 'send_signal(signal) methods which are\n self speaking.\n When you want to wait for the thread to end, use the 'join()' method:\n http://docs.python.org/library/threading.html#threading.Thread.join\n\n\n You want to launch the following bash commands without threading::\n\n [user@localhost ~]$ ls -l | grep pdf | wc -l\n 5\n\n here is how you can do it::\n\n >>> Ls = WrapCommand( 'ls -l')\n >>> GrepPdf = WrapCommand( 'grep pdf')\n >>> Wc = WrapCommand( 'wc -l')\n >>> Wc(GrepPdf(Ls))\n '5\\n'\n\n Avoid doing this for processes where a large amount of data is piped\n between each command.\n\n instead, do it this way::\n\n >>> Ls = WrapCommand( 'ls -l | grep pdf | wc -l', shell=True)\n >>> Ls()\n '5\\n'\n\n Prefer the threaded method instead if this may take a long time and\n that you want to perform other tasks in the meanwhile.\n\n\n You can specify another shell for running commands::\n\n >>> Ls = WrapCommand( 'ls', shell=True, executable='C:/windows/System32/WindowsPowerShell/v1.0/powershell.exe')\n >>> print Ls()\n\n Directory : C:\\Users\\Yves\\python_tests\n\n Mode LastWriteTime Length Name\n ---- ------------- ------ ----\n -a--- 27/01/2011 00:14 7006 commandwrapper.py\n -a--- 27/01/2011 00:15 7048 commandwrapper.pyc\n\n\n You can also use Context Management (with_item):\n http://docs.python.org/reference/compound_stmts.html#grammar-token-with_item\n\n example::\n\n >>> with WrapCommand( 'ls -l') as Ls:\n ... with WrapCommand( 'grep pdf') as GrepPdf:\n ... with WrapCommand( 'wc -l') as Wc:\n ... Wc.stdin = GrepPdf\n ... GrepPdf.stdin = Ls\n ... Wc.start( )\n ... #Do stuff\n ... Wc.join()\n ...\n >>> Wc.results\n ('5\\n', '')\n\n You may also simply want to have a subprocess objet::\n\n >>> ls = WrapCommand( 'ls -l')\n >>> lscmd = ls.makeCmd()\n >>>\n\n the returned object (`lscmd` in the example above) is a standard subprocess.Popen object\n \n\n WrapOnceCommand is the same as WrapCommand, but the cmd attribute\n which is a subprocess.Popen object will be created once and for all\n Therefore the run methode (or the object) can only be called once.\n The goal it to launch a command in a thread, and to have this\n command easily start/stopped from elsewhere.\n \n\n ===============\n Release Notes :\n ===============\n\n Release 0.1:\n ============\n\n First Version\n\n Release 0.4:\n ============\n\n Removed the destructor (__del__ method) because of:\n\n + The Warning here:\n http://docs.python.org/reference/datamodel.html#object.__del__\n\n + Destroyed objects where not automaticaly removed by the\n garbage collector as described here:\n http://docs.python.org/library/gc.html#gc.garbage\n Which could cause memory usage increase.\n\n Release 0.7:\n ============\n\n Changed author's contact info.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": null, "license": "GNU General Public License version 2.0", "maintainer": null, "maintainer_email": null, "name": "commandwrapper", "package_url": "https://pypi.org/project/commandwrapper/", "platform": "Windows,Linux,Mac OS", "project_url": "https://pypi.org/project/commandwrapper/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/commandwrapper/0.7/", "requires_dist": null, "requires_python": null, "summary": "Command Wrapper (make subprocess.Popen() easy)", "version": "0.7" }, "last_serial": 788323, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "4f685c8e65f7badf81d18533db43a0b2", "sha256": "e1d47694756f6553a4381493f036200cd468206035d3751921e8ea9c6dfbb886" }, "downloads": -1, "filename": "commandwrapper-0.1.tar.gz", "has_sig": false, "md5_digest": "4f685c8e65f7badf81d18533db43a0b2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3381, "upload_time": "2011-08-04T15:10:30", "url": "https://files.pythonhosted.org/packages/03/ef/1df131efb1f34ad4660346b007e99c7140bb14cd50b8ccb9b321257c0ab3/commandwrapper-0.1.tar.gz" } ], "0.2": [ { "comment_text": "built for Linux-2.6.33.7-desktop-2mnb-x86_64-with-glibc2.2.5", "digests": { "md5": "0db5c2e42f56a73c1fc0ed5697de0dca", "sha256": "909d688f7a1e65a2194b2fd846e73431c03920979a50ba603f7536cea97c930f" }, "downloads": -1, "filename": "commandwrapper-0.2.linux-x86_64.tar.gz", "has_sig": false, "md5_digest": "0db5c2e42f56a73c1fc0ed5697de0dca", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 5699, "upload_time": "2011-10-04T16:22:18", "url": "https://files.pythonhosted.org/packages/01/6c/5ee106b8a189dcadc2fa527d639726d582c5d5c3f744d3a98f911601f702/commandwrapper-0.2.linux-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "70d54a675dcf91d518354903aa0d4f92", "sha256": "969086f303d662fd322e68f08aa821c470b77dab0c91d73ca141e8c28e5bc3af" }, "downloads": -1, "filename": "commandwrapper-0.2.tar.gz", "has_sig": false, "md5_digest": "70d54a675dcf91d518354903aa0d4f92", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3512, "upload_time": "2011-10-04T16:18:17", "url": "https://files.pythonhosted.org/packages/a0/cc/61eca4a91dc421dda38d393f857818eb1693c0419d0fce90663384175902/commandwrapper-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "8f1f0dbc0641c5ec0380726d7c1943ff", "sha256": "59c8f48c37082ec5010d4f9173b36e0da9a211f785b1b8a5ff1fb666b8a9f78d" }, "downloads": -1, "filename": "commandwrapper-0.3.tar.gz", "has_sig": false, "md5_digest": "8f1f0dbc0641c5ec0380726d7c1943ff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3514, "upload_time": "2011-10-04T16:24:59", "url": "https://files.pythonhosted.org/packages/b3/ed/79e829d76200cd90f070ca3335b445bc2961effe7b4f065dc78c2957df95/commandwrapper-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "678eb3cd03aea0a570e6c4beb1af6ab9", "sha256": "c5b01b75590d281ae6ccb787374e532eccb54c949a9850a9c3634dc0bb4ebd68" }, "downloads": -1, "filename": "commandwrapper-0.4.tar.gz", "has_sig": false, "md5_digest": "678eb3cd03aea0a570e6c4beb1af6ab9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3735, "upload_time": "2011-10-05T10:48:37", "url": "https://files.pythonhosted.org/packages/fb/88/3d2380828f48ef19d25ec85eb26811472b45aee74ac95fef6d02a790790c/commandwrapper-0.4.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "ad660e424e3eb8a2d652fd122cccefd2", "sha256": "22f8993c21d5fb667251f458e7b0b93f8ccba226ae82f4a3d979fc3df827a724" }, "downloads": -1, "filename": "commandwrapper-0.6.zip", "has_sig": false, "md5_digest": "ad660e424e3eb8a2d652fd122cccefd2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5528, "upload_time": "2012-02-17T20:10:03", "url": "https://files.pythonhosted.org/packages/d3/de/32a665ab0e039f1f55e4c76e8ade98cb7239ad1f5b960b7d52dbb474ca48/commandwrapper-0.6.zip" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "a337bfbcc98dcb13cd85995e252a9d90", "sha256": "bf970f7bcbb3234dcce37889693cb96037ebc410283954dd119f4eecdb32d2b0" }, "downloads": -1, "filename": "commandwrapper-0.7.zip", "has_sig": false, "md5_digest": "a337bfbcc98dcb13cd85995e252a9d90", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5510, "upload_time": "2012-02-17T21:01:49", "url": "https://files.pythonhosted.org/packages/ff/62/c789bd6562e69a8703d6b5d5f2fe68d2f2182345d6217c9cb85a8d4c7fcb/commandwrapper-0.7.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a337bfbcc98dcb13cd85995e252a9d90", "sha256": "bf970f7bcbb3234dcce37889693cb96037ebc410283954dd119f4eecdb32d2b0" }, "downloads": -1, "filename": "commandwrapper-0.7.zip", "has_sig": false, "md5_digest": "a337bfbcc98dcb13cd85995e252a9d90", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5510, "upload_time": "2012-02-17T21:01:49", "url": "https://files.pythonhosted.org/packages/ff/62/c789bd6562e69a8703d6b5d5f2fe68d2f2182345d6217c9cb85a8d4c7fcb/commandwrapper-0.7.zip" } ] }