cmdbashinteractive


Namecmdbashinteractive JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/cmdbashinteractive
SummaryInteract with subprocesses running both bash.exe (CygWin) and cmd.exe without terminating them.
upload_time2023-11-04 03:53:16
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords bash cmd cygwin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Interact with subprocesses running both bash.exe (CygWin) and cmd.exe without terminating them.

## pip install cmdbashinteractive

```python


Args:
	print_stdout (bool, optional): Whether to print stdout from the subprocess (default is True).
	print_stderr (bool, optional): Whether to print stderr from the subprocess (default is True).
	limit_stdout (int, optional): Maximum number of lines to keep in stdout history (default is None).
	limit_stderr (int, optional): Maximum number of lines to keep in stderr history (default is None).
	limit_stdin (int, optional): Maximum number of lines to keep in stdin history (default is None).
	convert_to_83 (bool, optional): Whether to convert file paths to short (8.3) format (default is True).
	exitcommand (str, optional): The command to signal the subprocess to exit (default is "▓▓▓▓▓▓▓▓▓▓▓").
	newline (str, optional): The newline character to use (default is "\n").
	getcomspec (str, optional): The command to get the shell executable (default is "bash.exe").
	wait_to_complete (float, optional): The time to wait for subprocess completion (default is 0.1 seconds).
	**kwargs: Additional keyword arguments for subprocess.Popen.

import os

from cmdbashinteractive import BashInteractive, CmdInteractive

CREATE_NEW_PROCESS_GROUP = 0x00000200
DETACHED_PROCESS = 0x00000008


sh = BashInteractive(
    print_stdout=True,
    print_stderr=True,
    limit_stdout=None,
    limit_stderr=None,
    limit_stdin=None,
    convert_to_83=True,
    exitcommand="▓▓▓▓▓▓▓▓▓▓▓",
    newline="\n",
    getcomspec=r"C:\cygwin\bin\bash.exe",
    wait_to_complete=0.1,
    shell=False,  # **kwargs
    creationflags=DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP,  # **kwargs
    bufsize=0,  # **kwargs
    env=os.environ.copy(),  # **kwargs
)
stdo00, stde00 = sh("ls")
sh.install("tar")
stdo01, stde01 = sh("ping google.com | grep bytes")
stdo02, stde02 = sh(
    r"cat C:\yolov5max - Copy\2023_08_17.ini"
)  # automatically converted to 8.3 and afterwards to cygwin  when convert_to_83 is True
```


```python
Args:
	print_stdout (bool, optional): Whether to print stdout from the subprocess (default is True).
	print_stderr (bool, optional): Whether to print stderr from the subprocess (default is True).
	limit_stdout (int, optional): Maximum number of lines to keep in stdout history (default is None).
	limit_stderr (int, optional): Maximum number of lines to keep in stderr history (default is None).
	limit_stdin (int, optional): Maximum number of lines to keep in stdin history (default is None).
	convert_to_83 (bool, optional): Whether to convert file paths to short (8.3) format (default is True).
	exitcommand (str, optional): The command to signal the subprocess to exit (default is "▓▓▓▓▓▓▓▓▓▓▓").
	getcomspec (str, optional): The command to get the shell executable (default is None).
	newline (str, optional): The newline character to use (default is "\r\n").
	wait_to_complete (float, optional): The interval to check for subprocess completion (default is 0.1 seconds).
	**kwargs: Additional keyword arguments for subprocess.Popen.


cmd = CmdInteractive(
    print_stdout=True,
    print_stderr=True,
    limit_stdout=10,
    limit_stderr=10,
    limit_stdin=10,
    convert_to_83=True,
    exitcommand="▓▓▓▓▓▓▓▓▓▓▓",
    wait_to_complete=0.1,
    shell=False,  # **kwargs
    creationflags=DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP,  # **kwargs
    bufsize=0,  # **kwargs
    env=os.environ.copy(),  # **kwargs
    getcomspec=None,
    newline="\r\n",
)
#
strfi = sh(
    r"strings C:\yolov5max - Copy\2023_08_17.ini"
)  # automatically converted to 8.3 when convert_to_83 is True

stdo0, stde0 = cmd(f"ping google.com", wait_to_complete=0.1)
stdo1, stde1 = cmd(f"dir", wait_to_complete=0.1)
stdo2, stde2 = cmd(f"whoami.exe", wait_to_complete=0.1)
stdo3, stde3 = cmd(
    f"ping google.com", wait_to_complete=0
)  # non blocking, not recommended - might mess up stdout,stderr
stdo4, stde4 = cmd(
    f"dir", wait_to_complete=0
)  # non blocking, not recommended - might mess up stdout,stderr
stdo5, stde5 = cmd(
    f"whoami.exe", wait_to_complete=0
)  # non blocking, not recommended - might mess up stdout,stderr


```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/cmdbashinteractive",
    "name": "cmdbashinteractive",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "bash,cmd,cygwin",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ca/0b/75e1722b11cd7323500b130f99efdd1cc4da75b52d67ebd285a9142e9f27/cmdbashinteractive-0.10.tar.gz",
    "platform": null,
    "description": "\r\n# Interact with subprocesses running both bash.exe (CygWin) and cmd.exe without terminating them.\r\n\r\n## pip install cmdbashinteractive\r\n\r\n```python\r\n\r\n\r\nArgs:\r\n\tprint_stdout (bool, optional): Whether to print stdout from the subprocess (default is True).\r\n\tprint_stderr (bool, optional): Whether to print stderr from the subprocess (default is True).\r\n\tlimit_stdout (int, optional): Maximum number of lines to keep in stdout history (default is None).\r\n\tlimit_stderr (int, optional): Maximum number of lines to keep in stderr history (default is None).\r\n\tlimit_stdin (int, optional): Maximum number of lines to keep in stdin history (default is None).\r\n\tconvert_to_83 (bool, optional): Whether to convert file paths to short (8.3) format (default is True).\r\n\texitcommand (str, optional): The command to signal the subprocess to exit (default is \"\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\").\r\n\tnewline (str, optional): The newline character to use (default is \"\\n\").\r\n\tgetcomspec (str, optional): The command to get the shell executable (default is \"bash.exe\").\r\n\twait_to_complete (float, optional): The time to wait for subprocess completion (default is 0.1 seconds).\r\n\t**kwargs: Additional keyword arguments for subprocess.Popen.\r\n\r\nimport os\r\n\r\nfrom cmdbashinteractive import BashInteractive, CmdInteractive\r\n\r\nCREATE_NEW_PROCESS_GROUP = 0x00000200\r\nDETACHED_PROCESS = 0x00000008\r\n\r\n\r\nsh = BashInteractive(\r\n    print_stdout=True,\r\n    print_stderr=True,\r\n    limit_stdout=None,\r\n    limit_stderr=None,\r\n    limit_stdin=None,\r\n    convert_to_83=True,\r\n    exitcommand=\"\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\",\r\n    newline=\"\\n\",\r\n    getcomspec=r\"C:\\cygwin\\bin\\bash.exe\",\r\n    wait_to_complete=0.1,\r\n    shell=False,  # **kwargs\r\n    creationflags=DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP,  # **kwargs\r\n    bufsize=0,  # **kwargs\r\n    env=os.environ.copy(),  # **kwargs\r\n)\r\nstdo00, stde00 = sh(\"ls\")\r\nsh.install(\"tar\")\r\nstdo01, stde01 = sh(\"ping google.com | grep bytes\")\r\nstdo02, stde02 = sh(\r\n    r\"cat C:\\yolov5max - Copy\\2023_08_17.ini\"\r\n)  # automatically converted to 8.3 and afterwards to cygwin  when convert_to_83 is True\r\n```\r\n\r\n\r\n```python\r\nArgs:\r\n\tprint_stdout (bool, optional): Whether to print stdout from the subprocess (default is True).\r\n\tprint_stderr (bool, optional): Whether to print stderr from the subprocess (default is True).\r\n\tlimit_stdout (int, optional): Maximum number of lines to keep in stdout history (default is None).\r\n\tlimit_stderr (int, optional): Maximum number of lines to keep in stderr history (default is None).\r\n\tlimit_stdin (int, optional): Maximum number of lines to keep in stdin history (default is None).\r\n\tconvert_to_83 (bool, optional): Whether to convert file paths to short (8.3) format (default is True).\r\n\texitcommand (str, optional): The command to signal the subprocess to exit (default is \"\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\").\r\n\tgetcomspec (str, optional): The command to get the shell executable (default is None).\r\n\tnewline (str, optional): The newline character to use (default is \"\\r\\n\").\r\n\twait_to_complete (float, optional): The interval to check for subprocess completion (default is 0.1 seconds).\r\n\t**kwargs: Additional keyword arguments for subprocess.Popen.\r\n\r\n\r\ncmd = CmdInteractive(\r\n    print_stdout=True,\r\n    print_stderr=True,\r\n    limit_stdout=10,\r\n    limit_stderr=10,\r\n    limit_stdin=10,\r\n    convert_to_83=True,\r\n    exitcommand=\"\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\",\r\n    wait_to_complete=0.1,\r\n    shell=False,  # **kwargs\r\n    creationflags=DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP,  # **kwargs\r\n    bufsize=0,  # **kwargs\r\n    env=os.environ.copy(),  # **kwargs\r\n    getcomspec=None,\r\n    newline=\"\\r\\n\",\r\n)\r\n#\r\nstrfi = sh(\r\n    r\"strings C:\\yolov5max - Copy\\2023_08_17.ini\"\r\n)  # automatically converted to 8.3 when convert_to_83 is True\r\n\r\nstdo0, stde0 = cmd(f\"ping google.com\", wait_to_complete=0.1)\r\nstdo1, stde1 = cmd(f\"dir\", wait_to_complete=0.1)\r\nstdo2, stde2 = cmd(f\"whoami.exe\", wait_to_complete=0.1)\r\nstdo3, stde3 = cmd(\r\n    f\"ping google.com\", wait_to_complete=0\r\n)  # non blocking, not recommended - might mess up stdout,stderr\r\nstdo4, stde4 = cmd(\r\n    f\"dir\", wait_to_complete=0\r\n)  # non blocking, not recommended - might mess up stdout,stderr\r\nstdo5, stde5 = cmd(\r\n    f\"whoami.exe\", wait_to_complete=0\r\n)  # non blocking, not recommended - might mess up stdout,stderr\r\n\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Interact with subprocesses running both bash.exe (CygWin) and cmd.exe without terminating them.",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/cmdbashinteractive"
    },
    "split_keywords": [
        "bash",
        "cmd",
        "cygwin"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "19f128d8a587c15a2c12004bd2afaa61a73a69cde83cb424dbbf8d690adeedbd",
                "md5": "fb5033f160fffaa91110bcfc12e0303d",
                "sha256": "cdcc9df49c60da7b8d3489419bdb0310493d8fe13096cd1fc33bd9bbd869afd8"
            },
            "downloads": -1,
            "filename": "cmdbashinteractive-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fb5033f160fffaa91110bcfc12e0303d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 16734,
            "upload_time": "2023-11-04T03:53:14",
            "upload_time_iso_8601": "2023-11-04T03:53:14.700203Z",
            "url": "https://files.pythonhosted.org/packages/19/f1/28d8a587c15a2c12004bd2afaa61a73a69cde83cb424dbbf8d690adeedbd/cmdbashinteractive-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ca0b75e1722b11cd7323500b130f99efdd1cc4da75b52d67ebd285a9142e9f27",
                "md5": "093ffbd7bfbd6e584377f0082ade10fb",
                "sha256": "d9a505abf66aba21ec9713503e992614cc1af44d52e0b3b45a19015888cb0d1a"
            },
            "downloads": -1,
            "filename": "cmdbashinteractive-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "093ffbd7bfbd6e584377f0082ade10fb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15309,
            "upload_time": "2023-11-04T03:53:16",
            "upload_time_iso_8601": "2023-11-04T03:53:16.297185Z",
            "url": "https://files.pythonhosted.org/packages/ca/0b/75e1722b11cd7323500b130f99efdd1cc4da75b52d67ebd285a9142e9f27/cmdbashinteractive-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-04 03:53:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "cmdbashinteractive",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "cmdbashinteractive"
}
        
Elapsed time: 0.15766s