Skip to main content

Provides cross-platform tools for handling the context of a Python application, including getting system, user and application info.

Project description

Test Coverage Stable Version Pre-release Version PyPI - Python Version PyPI Downloads

app-runtime

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

Example

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

app_runtime-0.0.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

app_runtime-0.0.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file app_runtime-0.0.0.tar.gz.

File metadata

  • Download URL: app_runtime-0.0.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for app_runtime-0.0.0.tar.gz
Algorithm Hash digest
SHA256 082c2362c060ba1a11e4b9b83cc7ebd3a27fb938906ce76fe4cc1f9571704a9c
MD5 02ef0c45302c04275892874c05fdbb0f
BLAKE2b-256 a9d45697614f8c4aefced5b35bed3f9db196fc8e4bb6d52ae98666c4fe37d5c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for app_runtime-0.0.0.tar.gz:

Publisher: python-publish.yml on apmadsen/app-runtime

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file app_runtime-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: app_runtime-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for app_runtime-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0142ca6ce7ea69bfdcaa6c1816acfe555a66f98d74aed923cde919634513e8c9
MD5 9bd0cdca51f5ea9e2983f5c6487c85e4
BLAKE2b-256 b6e5c490db8c54092b569e2b1db8a6ac575781eb71eef17ea9e4de4a9dabd7e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for app_runtime-0.0.0-py3-none-any.whl:

Publisher: python-publish.yml on apmadsen/app-runtime

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page