rlogfi


Namerlogfi JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/rlogfi
SummaryDetached PowerShell interactive session, but with full control
upload_time2024-03-22 07:43:08
maintainerNone
docs_urlNone
authorJohannes Fischer
requires_pythonNone
licenseMIT
keywords powershell asyncio
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            

## rlogfi provides a way to interact with PowerShell subprocesses in a detached and asynchronous manner

## pip install rlogfi

### Tested against Windows 10 / Python 3.11 / Anaconda / BlueStacks

### Asynchronous I/O: 
By using asyncio and aiofiles, the script can perform I/O operations asynchronously, allowing for more efficient handling of multiple subprocess streams simultaneously. This can be particularly useful when dealing with long-running commands or when responsiveness is crucial. It also helps to avoid deadlocks, since Start-Process allows the redirection of stdout/stdin: -RedirectStandardOutput / -RedirectStandardError 

### Detached Execution: 
The script creates a detached subprocess for running PowerShell commands, which means it operates independently of the parent process. This can be advantageous in scenarios where you need to run commands in the background or interact with PowerShell without blocking the main Python program. Instead of cmd.exe, you can start any other app that loops forever (e.g., a proxy server). The process won't close when Python closes.

### Error Handling and Reconnection: 
The script includes error handling mechanisms to handle exceptions and reconnect to the subprocess if the connection to stdin is lost. This ensures robustness in scenarios where the subprocess may encounter issues or terminate unexpectedly.

### Customization and Control: 
The class structure allows for customization of various parameters such as execution policy, working directory, and output redirection. Users can tailor the behavior of the subprocess to suit their specific requirements.

```py 
from rlogfi import PowerShellDetachedInteractive

interactivepwsh = PowerShellDetachedInteractive(
    executable=r"c:\windows\system32\cmd.exe",
    logfolder="c:\\newlogggg",
    working_dir=None,
    execution_policy="Unrestricted",
    arguments=["dir", "c:\\Windows"],
    WhatIf="",
    Verb="",
    UseNewEnvironment="",
    Wait="",
    stdinadd="",
    WindowStyle="Hidden",
)

# executing commandos 
stdout, stderr = interactivepwsh.sendcommand("dir")
print(stdout, stderr)
so, se = interactivepwsh.sendcommand("netstat")
so, se = interactivepwsh.sendcommand("cd\\")
so, se = interactivepwsh.sendcommand("ls")
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/rlogfi",
    "name": "rlogfi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "PowerShell, Asyncio",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4c/6e/75793f4e2ab0c93d3ae079c17709ec392e091875c562e3c3be3543c7ec73/rlogfi-0.10.tar.gz",
    "platform": null,
    "description": "\r\n\r\n## rlogfi provides a way to interact with PowerShell subprocesses in a detached and asynchronous manner\r\n\r\n## pip install rlogfi\r\n\r\n### Tested against Windows 10 / Python 3.11 / Anaconda / BlueStacks\r\n\r\n### Asynchronous I/O: \r\nBy using asyncio and aiofiles, the script can perform I/O operations asynchronously, allowing for more efficient handling of multiple subprocess streams simultaneously. This can be particularly useful when dealing with long-running commands or when responsiveness is crucial. It also helps to avoid deadlocks, since Start-Process allows the redirection of stdout/stdin: -RedirectStandardOutput / -RedirectStandardError \r\n\r\n### Detached Execution: \r\nThe script creates a detached subprocess for running PowerShell commands, which means it operates independently of the parent process. This can be advantageous in scenarios where you need to run commands in the background or interact with PowerShell without blocking the main Python program. Instead of cmd.exe, you can start any other app that loops forever (e.g., a proxy server). The process won't close when Python closes.\r\n\r\n### Error Handling and Reconnection: \r\nThe script includes error handling mechanisms to handle exceptions and reconnect to the subprocess if the connection to stdin is lost. This ensures robustness in scenarios where the subprocess may encounter issues or terminate unexpectedly.\r\n\r\n### Customization and Control: \r\nThe class structure allows for customization of various parameters such as execution policy, working directory, and output redirection. Users can tailor the behavior of the subprocess to suit their specific requirements.\r\n\r\n```py \r\nfrom rlogfi import PowerShellDetachedInteractive\r\n\r\ninteractivepwsh = PowerShellDetachedInteractive(\r\n    executable=r\"c:\\windows\\system32\\cmd.exe\",\r\n    logfolder=\"c:\\\\newlogggg\",\r\n    working_dir=None,\r\n    execution_policy=\"Unrestricted\",\r\n    arguments=[\"dir\", \"c:\\\\Windows\"],\r\n    WhatIf=\"\",\r\n    Verb=\"\",\r\n    UseNewEnvironment=\"\",\r\n    Wait=\"\",\r\n    stdinadd=\"\",\r\n    WindowStyle=\"Hidden\",\r\n)\r\n\r\n# executing commandos \r\nstdout, stderr = interactivepwsh.sendcommand(\"dir\")\r\nprint(stdout, stderr)\r\nso, se = interactivepwsh.sendcommand(\"netstat\")\r\nso, se = interactivepwsh.sendcommand(\"cd\\\\\")\r\nso, se = interactivepwsh.sendcommand(\"ls\")\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Detached PowerShell interactive session, but with full control",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/rlogfi"
    },
    "split_keywords": [
        "powershell",
        " asyncio"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "539203f6e970bd9fb6d2507755527a9a393c2d2dd46befb7cf5a3499298b808c",
                "md5": "44d49b23f9f0e12f885724f9a48bfdc4",
                "sha256": "47501f63de0aa74cdc97189aeed2bd8979b315fd98107cc6c1b05f9c30afbe0e"
            },
            "downloads": -1,
            "filename": "rlogfi-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "44d49b23f9f0e12f885724f9a48bfdc4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 13277,
            "upload_time": "2024-03-22T07:43:06",
            "upload_time_iso_8601": "2024-03-22T07:43:06.127732Z",
            "url": "https://files.pythonhosted.org/packages/53/92/03f6e970bd9fb6d2507755527a9a393c2d2dd46befb7cf5a3499298b808c/rlogfi-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c6e75793f4e2ab0c93d3ae079c17709ec392e091875c562e3c3be3543c7ec73",
                "md5": "b9eb3ecfd821307eb2ba0fa810aa1817",
                "sha256": "d81e8b1459080efdcf3bf4ddd49a2a43586bb3e77ffa79df2fea1db9c8b11750"
            },
            "downloads": -1,
            "filename": "rlogfi-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "b9eb3ecfd821307eb2ba0fa810aa1817",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13284,
            "upload_time": "2024-03-22T07:43:08",
            "upload_time_iso_8601": "2024-03-22T07:43:08.011812Z",
            "url": "https://files.pythonhosted.org/packages/4c/6e/75793f4e2ab0c93d3ae079c17709ec392e091875c562e3c3be3543c7ec73/rlogfi-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-22 07:43:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "rlogfi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "rlogfi"
}
        
Elapsed time: 0.21401s