app-runtime


Nameapp-runtime JSON
Version 0.0.1 PyPI version JSON
download
home_pageNone
SummaryProvides cross-platform tools for handling the context of a Python application, including getting system, user and application info.
upload_time2025-07-20 10:40:13
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords windows linux
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            [![Test](https://github.com/apmadsen/app-runtime/actions/workflows/python-test.yml/badge.svg)](https://github.com/apmadsen/app-runtime/actions/workflows/python-test.yml)
[![Coverage](https://github.com/apmadsen/app-runtime/actions/workflows/python-test-coverage.yml/badge.svg)](https://github.com/apmadsen/app-runtime/actions/workflows/python-test-coverage.yml)
[![Stable Version](https://img.shields.io/pypi/v/app-runtime?label=stable&sort=semver&color=blue)](https://github.com/apmadsen/app-runtime/releases)
![Pre-release Version](https://img.shields.io/github/v/release/apmadsen/app-runtime?label=pre-release&include_prereleases&sort=semver&color=blue)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/app-runtime)
[![PyPI Downloads](https://static.pepy.tech/badge/app-runtime/week)](https://pepy.tech/projects/app-runtime)

# app-runtime
This project provides cross-platform tools for handling the context of a Python application, including getting system, user and application info.

## Example

```python
from runtime.application import (
    get_main_module_name, get_application_path, hook_terminate,
    is_interactive, is_python_shell, single_instance,
    SingleInstanceException, TerminateException
)
from runtime.user import get_username, is_elevated

hook_terminate()
username = get_username()
module = get_main_module_name()
app_path = get_application_path()
interactive = is_interactive()
is_shell = is_python_shell()

def output(line: str):
    if interactive:
        print(line)

try:
    with single_instance():
        try:
            output(f"Hello {'admin ' if is_elevated() else ''}{username}, this is {module} located in {app_path}")
            output(f"I can tell that you're{' not' if not is_shell else ''} running this script in a python shell")
        except TerminateException:
            output(f"Bye {username}")
        except:
            output("An unexpected error ocurred")
except SingleInstanceException:
    output("Another instance of this application is already running!")

```
## Full documentation

[Go to documentation](https://github.com/apmadsen/app-runtime/blob/main/docs/documentation.md)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "app-runtime",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "windows, linux",
    "author": null,
    "author_email": "Anders Madsen <anders.madsen@alphavue.com>",
    "download_url": "https://files.pythonhosted.org/packages/67/41/349b7cc3ac32edea72733def7d980a2ed8f6f48f947d3216e704b1596123/app_runtime-0.0.1.tar.gz",
    "platform": null,
    "description": "[![Test](https://github.com/apmadsen/app-runtime/actions/workflows/python-test.yml/badge.svg)](https://github.com/apmadsen/app-runtime/actions/workflows/python-test.yml)\n[![Coverage](https://github.com/apmadsen/app-runtime/actions/workflows/python-test-coverage.yml/badge.svg)](https://github.com/apmadsen/app-runtime/actions/workflows/python-test-coverage.yml)\n[![Stable Version](https://img.shields.io/pypi/v/app-runtime?label=stable&sort=semver&color=blue)](https://github.com/apmadsen/app-runtime/releases)\n![Pre-release Version](https://img.shields.io/github/v/release/apmadsen/app-runtime?label=pre-release&include_prereleases&sort=semver&color=blue)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/app-runtime)\n[![PyPI Downloads](https://static.pepy.tech/badge/app-runtime/week)](https://pepy.tech/projects/app-runtime)\n\n# app-runtime\nThis project provides cross-platform tools for handling the context of a Python application, including getting system, user and application info.\n\n## Example\n\n```python\nfrom runtime.application import (\n    get_main_module_name, get_application_path, hook_terminate,\n    is_interactive, is_python_shell, single_instance,\n    SingleInstanceException, TerminateException\n)\nfrom runtime.user import get_username, is_elevated\n\nhook_terminate()\nusername = get_username()\nmodule = get_main_module_name()\napp_path = get_application_path()\ninteractive = is_interactive()\nis_shell = is_python_shell()\n\ndef output(line: str):\n    if interactive:\n        print(line)\n\ntry:\n    with single_instance():\n        try:\n            output(f\"Hello {'admin ' if is_elevated() else ''}{username}, this is {module} located in {app_path}\")\n            output(f\"I can tell that you're{' not' if not is_shell else ''} running this script in a python shell\")\n        except TerminateException:\n            output(f\"Bye {username}\")\n        except:\n            output(\"An unexpected error ocurred\")\nexcept SingleInstanceException:\n    output(\"Another instance of this application is already running!\")\n\n```\n## Full documentation\n\n[Go to documentation](https://github.com/apmadsen/app-runtime/blob/main/docs/documentation.md)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Provides cross-platform tools for handling the context of a Python application, including getting system, user and application info.",
    "version": "0.0.1",
    "project_urls": {
        "repository": "https://github.com/apmadsen/app-runtime"
    },
    "split_keywords": [
        "windows",
        " linux"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d2e828a8aa40c0c49bf55c88c2fcded2f0e1502350cba85f2c06f044365b7b22",
                "md5": "ea93b5544663bb1d5e53784a897480cf",
                "sha256": "e2a49500d72ac89d6bbe257b20c705b01da8c7bd960e4ae6d23eeb6e943c38db"
            },
            "downloads": -1,
            "filename": "app_runtime-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ea93b5544663bb1d5e53784a897480cf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 16721,
            "upload_time": "2025-07-20T10:40:11",
            "upload_time_iso_8601": "2025-07-20T10:40:11.981724Z",
            "url": "https://files.pythonhosted.org/packages/d2/e8/28a8aa40c0c49bf55c88c2fcded2f0e1502350cba85f2c06f044365b7b22/app_runtime-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6741349b7cc3ac32edea72733def7d980a2ed8f6f48f947d3216e704b1596123",
                "md5": "9e8fa7b4f1b576a27dc9ee5198e055b7",
                "sha256": "92911268e6e07573f90b2b7f42285356404033d659aa156292eb79f40f76a135"
            },
            "downloads": -1,
            "filename": "app_runtime-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9e8fa7b4f1b576a27dc9ee5198e055b7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 13061,
            "upload_time": "2025-07-20T10:40:13",
            "upload_time_iso_8601": "2025-07-20T10:40:13.470876Z",
            "url": "https://files.pythonhosted.org/packages/67/41/349b7cc3ac32edea72733def7d980a2ed8f6f48f947d3216e704b1596123/app_runtime-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-20 10:40:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "apmadsen",
    "github_project": "app-runtime",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "app-runtime"
}
        
Elapsed time: 1.04942s