Elevate: Request root privileges
Elevate is a small Python library that re-launches the current process with root/admin privileges using one of the following mechanisms:
UAC (Windows)
AppleScript (macOS)
pkexec, gksudo or kdesudo (Linux)
sudo (Linux, macOS)
Usage
To use, call elevate.elevate() early in your script. When run as root this function does nothing. When not run as root, this function replaces the current process (Linux, macOS) or creates a new process, waits, and exits (Windows). Consider the following example:
import os
from elevate import elevate
def is_root():
return os.getuid() == 0
print("before ", is_root())
elevate()
print("after ", is_root())
This prints:
before False before True after True
On Windows, the new process’s standard streams are not attached to the parent, which is an inherent limitation of UAC. By default the new process runs in a new console window. To suppress this window, use elevate(show_console=False).
On Linux and macOS, graphical prompts are tried before sudo by default. To prevent graphical prompts, use elevate(graphical=False).
Metadata
Release files for elevate 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| elevate-0.1.3.tar.gz | 2.9 kB | Without provenance | Details |
Release files / elevate-0.1.3.tar.gz
| Download URL | elevate-0.1.3.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53ad19fa1de301fb1de3f8768fb3a5894215716fd96a475690c4d0ff3b1de209
|
|
BLAKE2b-256 checksum How to use checksums |
813229ba61063ac124632754e26c65e71217f48ce682fbf8762ee9a0bb0d32de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for elevate 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.