Provides cross-platform tools for handling the context of a Python application, including getting system, user and application info.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92911268e6e07573f90b2b7f42285356404033d659aa156292eb79f40f76a135
|
|
| MD5 |
9e8fa7b4f1b576a27dc9ee5198e055b7
|
|
| BLAKE2b-256 |
6741349b7cc3ac32edea72733def7d980a2ed8f6f48f947d3216e704b1596123
|
Provenance
The following attestation bundles were made for app_runtime-0.0.1.tar.gz:
Publisher:
python-publish.yml on apmadsen/app-runtime
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
app_runtime-0.0.1.tar.gz -
Subject digest:
92911268e6e07573f90b2b7f42285356404033d659aa156292eb79f40f76a135 - Sigstore transparency entry: 295316291
- Sigstore integration time:
-
Permalink:
apmadsen/app-runtime@6c589dc01f5e92164f2f3cc9b071349fb9f2bf32 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/apmadsen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6c589dc01f5e92164f2f3cc9b071349fb9f2bf32 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2a49500d72ac89d6bbe257b20c705b01da8c7bd960e4ae6d23eeb6e943c38db
|
|
| MD5 |
ea93b5544663bb1d5e53784a897480cf
|
|
| BLAKE2b-256 |
d2e828a8aa40c0c49bf55c88c2fcded2f0e1502350cba85f2c06f044365b7b22
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
app_runtime-0.0.1-py3-none-any.whl -
Subject digest:
e2a49500d72ac89d6bbe257b20c705b01da8c7bd960e4ae6d23eeb6e943c38db - Sigstore transparency entry: 295316297
- Sigstore integration time:
-
Permalink:
apmadsen/app-runtime@6c589dc01f5e92164f2f3cc9b071349fb9f2bf32 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/apmadsen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6c589dc01f5e92164f2f3cc9b071349fb9f2bf32 -
Trigger Event:
release
-
Statement type: