Check whether the current Python process is running as an administrator or root user.
Project description
is-admin-user
Check whether the current Python process is running as an administrator.
is-admin-user is a tiny, dependency-free Python package that works across
Windows, Linux, and macOS. It exposes a programmable function interface for
checking whether the current process has administrative privileges.
Installation
pip install is-admin-user
For local development:
pip install -e .
Usage
from is_admin_user import is_admin_user
if is_admin_user():
print("Running as administrator/root")
else:
print("Running as a standard user")
You can also use the shorter alias:
from is_admin_user import is_admin
if is_admin():
print("Administrative privileges are available")
Platform behavior
- Windows: returns
Truewhen the current process token is running with administrator privileges. - Linux: returns
Truewhen the effective user ID is0(root). - macOS: returns
Truewhen the effective user ID is0(root).
On Windows, an account that belongs to the Administrators group may still return
False if the Python process was not started with elevated privileges.
API
is_admin_user() -> bool
Returns True when the current Python process has administrator/root
privileges, otherwise returns False.
is_admin() -> bool
Alias for is_admin_user().
Development
Run the test suite with:
python -m pytest
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 is_admin_user-0.1.0.tar.gz.
File metadata
- Download URL: is_admin_user-0.1.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
051ecbd4c07153524536b18e7bbbc98726ee87e065c3ce90875e20eef53a9f2e
|
|
| MD5 |
f7550d41dc5d4878d49889786fc12b14
|
|
| BLAKE2b-256 |
28917a08171dd639f265c5df756dc34893def771d564303b8682d87230293111
|
File details
Details for the file is_admin_user-0.1.0-py3-none-any.whl.
File metadata
- Download URL: is_admin_user-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4418ea0bfa16d09e982f16063b6c9488f68f153c81e3527fb0cae1cbcd134680
|
|
| MD5 |
4cd9507ca0cc01d182e60d1290a70fd7
|
|
| BLAKE2b-256 |
c7da6d12a81135e770f18af2653e030cf4c9c1f912ee82940e7967c32a3b7a1b
|