constant-check-and-kill


Nameconstant-check-and-kill JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/constant_check_and_kill
SummaryConvenient and customizable solution for monitoring and terminating processes - Windows only
upload_time2023-05-31 07:04:51
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords killing processes
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Convenient and customizable solution for monitoring and terminating processes - Windows only

## pip install constant-check-and-kill

#### Tested against Windows 10 / Python 3.10 / Anaconda


The constant_check_and_kill module provides a convenient and customizable solution for monitoring and terminating processes, offering users greater control and automation in managing their system's processes.

It can be useful for system administrators, developers, or users who need to monitor and terminate specific processes based on configurable criteria. Here are some potential use cases and advantages of using this module:



### Flexibility: 

The module provides configurable options such as executable path patterns, regular expression support, and delay between process checks, allowing users to tailor the process monitoring and termination behavior to their specific needs.


### Automation: 

The module allows for continuous monitoring and automatic termination of processes, reducing the need for manual intervention and saving time.

### Customization: 

Users can define their own process termination criteria based on executable path patterns or regular expressions, giving them fine-grained control over which processes to target.

### Scalability: 

The module can handle multiple processes simultaneously, making it suitable for environments with a large number of processes to monitor and terminate.

### Control: 

Users can choose to terminate only the first matching process or continue monitoring and terminating subsequent matches, providing flexibility in managing process termination behavior.


```python
constant_check_and_kill(
    exe_path: str | None = None,
    is_regex: int | bool = 1,
    flags: int = re.I,
    delay: float | int = 1.0,
    close_after_first: int | bool = 0,
):
    r"""
    Continuously checks for running processes and kills them if they match the specified criteria.

    Args:
        exe_path (str | None): The path or regex pattern of the processes to be killed.
        is_regex (int | bool): Flag indicating if `exe_path` is a regex pattern (default: 1).
        flags (int): Additional flags for the regex pattern matching (default: re.I).
        delay (float | int): Delay in seconds between process checks (default: 1.0).
        close_after_first (int | bool): Flag indicating whether to exit after killing the first matching process (default: 0).

    Returns:
        Callable[[], None]: A partial function that can be used to stop the continuous process checking and killing.

    Raises:
        None

    Example usage:

    Killing one process - function call:
    This example demonstrates how to kill a single process by calling the kill_proc function with the desired process ID (PID).
    The process with the specified PID will be terminated.

    kill_proc(pid=21360)
    ############################################################
    Constantly checking if processes exist and kill them - CLI:
    This example shows how to use the script from the command line to continuously monitor and kill processes that match a
    specific executable path pattern. The command should be executed in the following format:

    python .\constant_kill_procs.py --exe_path "(?:calculator.exe|chrome.exe)$" --is_regex 1 --flags 2 --delay 0.1 --close_after_first 0
    --exe_path: The regular expression pattern specifying the executable path(s) of the target processes.
    --is_regex: A flag indicating whether the exe_path argument should be treated as a regular expression (1 for True, 0 for False).
    --flags: Additional flags for the regular expression pattern matching.
    --delay: The delay in seconds between each process check.
    --close_after_first: A flag indicating whether to exit the script after killing the first matching process (1 for True, 0 for False).
    ############################################################
    Constantly checking if processes exist and kill them - function call:
    This example demonstrates how to continuously monitor and kill processes that match a specific executable path pattern
    by calling the constant_check_and_kill function directly.
    from constant_check_and_kill import constant_check_and_kill

    constant_check_and_kill(
        exe_path="notepad.exe$",
        is_regex=True,
        flags=re.I,
        delay=1.0,
        close_after_first=False,
    )
    exe_path: The regular expression pattern or exact executable path of the target processes.
    is_regex: A flag indicating whether the exe_path argument should be treated as a regular expression (True) or an exact path (False).
    flags: Additional flags for the regular expression pattern matching.
    delay: The delay in seconds between each process check.
    close_after_first: A flag indicating whether to exit the script after killing the first matching process (True) or
    continue monitoring and killing other matching processes (False).
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/constant_check_and_kill",
    "name": "constant-check-and-kill",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "killing,processes",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a3/6e/34f7979736665fc643d90aab9793ac469a350f12d97ea9eed4e868dda948/constant_check_and_kill-0.10.tar.gz",
    "platform": null,
    "description": "\r\n# Convenient and customizable solution for monitoring and terminating processes - Windows only\r\n\r\n## pip install constant-check-and-kill\r\n\r\n#### Tested against Windows 10 / Python 3.10 / Anaconda\r\n\r\n\r\nThe constant_check_and_kill module provides a convenient and customizable solution for monitoring and terminating processes, offering users greater control and automation in managing their system's processes.\r\n\r\nIt can be useful for system administrators, developers, or users who need to monitor and terminate specific processes based on configurable criteria. Here are some potential use cases and advantages of using this module:\r\n\r\n\r\n\r\n### Flexibility: \r\n\r\nThe module provides configurable options such as executable path patterns, regular expression support, and delay between process checks, allowing users to tailor the process monitoring and termination behavior to their specific needs.\r\n\r\n\r\n### Automation: \r\n\r\nThe module allows for continuous monitoring and automatic termination of processes, reducing the need for manual intervention and saving time.\r\n\r\n### Customization: \r\n\r\nUsers can define their own process termination criteria based on executable path patterns or regular expressions, giving them fine-grained control over which processes to target.\r\n\r\n### Scalability: \r\n\r\nThe module can handle multiple processes simultaneously, making it suitable for environments with a large number of processes to monitor and terminate.\r\n\r\n### Control: \r\n\r\nUsers can choose to terminate only the first matching process or continue monitoring and terminating subsequent matches, providing flexibility in managing process termination behavior.\r\n\r\n\r\n```python\r\nconstant_check_and_kill(\r\n    exe_path: str | None = None,\r\n    is_regex: int | bool = 1,\r\n    flags: int = re.I,\r\n    delay: float | int = 1.0,\r\n    close_after_first: int | bool = 0,\r\n):\r\n    r\"\"\"\r\n    Continuously checks for running processes and kills them if they match the specified criteria.\r\n\r\n    Args:\r\n        exe_path (str | None): The path or regex pattern of the processes to be killed.\r\n        is_regex (int | bool): Flag indicating if `exe_path` is a regex pattern (default: 1).\r\n        flags (int): Additional flags for the regex pattern matching (default: re.I).\r\n        delay (float | int): Delay in seconds between process checks (default: 1.0).\r\n        close_after_first (int | bool): Flag indicating whether to exit after killing the first matching process (default: 0).\r\n\r\n    Returns:\r\n        Callable[[], None]: A partial function that can be used to stop the continuous process checking and killing.\r\n\r\n    Raises:\r\n        None\r\n\r\n    Example usage:\r\n\r\n    Killing one process - function call:\r\n    This example demonstrates how to kill a single process by calling the kill_proc function with the desired process ID (PID).\r\n    The process with the specified PID will be terminated.\r\n\r\n    kill_proc(pid=21360)\r\n    ############################################################\r\n    Constantly checking if processes exist and kill them - CLI:\r\n    This example shows how to use the script from the command line to continuously monitor and kill processes that match a\r\n    specific executable path pattern. The command should be executed in the following format:\r\n\r\n    python .\\constant_kill_procs.py --exe_path \"(?:calculator.exe|chrome.exe)$\" --is_regex 1 --flags 2 --delay 0.1 --close_after_first 0\r\n    --exe_path: The regular expression pattern specifying the executable path(s) of the target processes.\r\n    --is_regex: A flag indicating whether the exe_path argument should be treated as a regular expression (1 for True, 0 for False).\r\n    --flags: Additional flags for the regular expression pattern matching.\r\n    --delay: The delay in seconds between each process check.\r\n    --close_after_first: A flag indicating whether to exit the script after killing the first matching process (1 for True, 0 for False).\r\n    ############################################################\r\n    Constantly checking if processes exist and kill them - function call:\r\n    This example demonstrates how to continuously monitor and kill processes that match a specific executable path pattern\r\n    by calling the constant_check_and_kill function directly.\r\n    from constant_check_and_kill import constant_check_and_kill\r\n\r\n    constant_check_and_kill(\r\n        exe_path=\"notepad.exe$\",\r\n        is_regex=True,\r\n        flags=re.I,\r\n        delay=1.0,\r\n        close_after_first=False,\r\n    )\r\n    exe_path: The regular expression pattern or exact executable path of the target processes.\r\n    is_regex: A flag indicating whether the exe_path argument should be treated as a regular expression (True) or an exact path (False).\r\n    flags: Additional flags for the regular expression pattern matching.\r\n    delay: The delay in seconds between each process check.\r\n    close_after_first: A flag indicating whether to exit the script after killing the first matching process (True) or\r\n    continue monitoring and killing other matching processes (False).\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Convenient and customizable solution for monitoring and terminating processes - Windows only",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/constant_check_and_kill"
    },
    "split_keywords": [
        "killing",
        "processes"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "da679c724f5084e989a975842c108c51a2f4969bb4b5e4cef66c879bd2207c6f",
                "md5": "a9ba304f9a8019ee824f81911327baf8",
                "sha256": "cb17cfc1fc6809871030c8d8c7340ba03e441a11d36e04e415d8baed5bab19f2"
            },
            "downloads": -1,
            "filename": "constant_check_and_kill-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a9ba304f9a8019ee824f81911327baf8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 9834,
            "upload_time": "2023-05-31T07:04:49",
            "upload_time_iso_8601": "2023-05-31T07:04:49.475973Z",
            "url": "https://files.pythonhosted.org/packages/da/67/9c724f5084e989a975842c108c51a2f4969bb4b5e4cef66c879bd2207c6f/constant_check_and_kill-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a36e34f7979736665fc643d90aab9793ac469a350f12d97ea9eed4e868dda948",
                "md5": "c2c32ad8525272291b14aa6992390944",
                "sha256": "33e4afdb11d694010622c53e85fa9cf41d8e433374f574c6abda3f94ca9f29aa"
            },
            "downloads": -1,
            "filename": "constant_check_and_kill-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "c2c32ad8525272291b14aa6992390944",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7097,
            "upload_time": "2023-05-31T07:04:51",
            "upload_time_iso_8601": "2023-05-31T07:04:51.794496Z",
            "url": "https://files.pythonhosted.org/packages/a3/6e/34f7979736665fc643d90aab9793ac469a350f12d97ea9eed4e868dda948/constant_check_and_kill-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-31 07:04:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "constant_check_and_kill",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "constant-check-and-kill"
}
        
Elapsed time: 0.09945s