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.1.tar.gz (13.1 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.1-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: app_runtime-0.0.1.tar.gz
  • Upload date:
  • Size: 13.1 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.1.tar.gz
Algorithm Hash digest
SHA256 92911268e6e07573f90b2b7f42285356404033d659aa156292eb79f40f76a135
MD5 9e8fa7b4f1b576a27dc9ee5198e055b7
BLAKE2b-256 6741349b7cc3ac32edea72733def7d980a2ed8f6f48f947d3216e704b1596123

See more details on using hashes here.

Provenance

The following attestation bundles were made for app_runtime-0.0.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: app_runtime-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e2a49500d72ac89d6bbe257b20c705b01da8c7bd960e4ae6d23eeb6e943c38db
MD5 ea93b5544663bb1d5e53784a897480cf
BLAKE2b-256 d2e828a8aa40c0c49bf55c88c2fcded2f0e1502350cba85f2c06f044365b7b22

See more details on using hashes here.

Provenance

The following attestation bundles were made for app_runtime-0.0.1-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